Forráskód Böngészése

add UIView extension to position a view to the trailing of another view

cyberta 6 éve
szülő
commit
d78e7e7b64

+ 9 - 0
deltachat-ios/Handler/QRCodeHandler.swift

@@ -0,0 +1,9 @@
+//
+//  QRCodeHandler.swift
+//  deltachat-ios
+//
+//  Created by Macci on 06.08.19.
+//  Copyright © 2019 Jonas Reinsch. All rights reserved.
+//
+
+import Foundation

+ 12 - 0
deltachat-ios/Helper/UIView+Extension.swift

@@ -73,6 +73,18 @@ extension UIView {
 			constant: paddingTop)
 	}
 
+	func constraintToTrailingOf(_ view: UIView, paddingLeading: CGFloat = 0.0) -> NSLayoutConstraint {
+		return NSLayoutConstraint(
+			item: self,
+			attribute: .leading,
+			relatedBy: .equal,
+			toItem: view,
+			attribute: .trailing,
+			multiplier: 1.0,
+			constant: paddingLeading)
+	}
+
+
 	func constraintCenterXTo(_ view: UIView, paddingX: CGFloat = 0.0) -> NSLayoutConstraint {
 		return NSLayoutConstraint(item: self,
 								  attribute: .centerX,