Pārlūkot izejas kodu

add UIView extension to align a view's bottom to another view's bottom

cyberta 6 gadi atpakaļ
vecāks
revīzija
39af55888c
1 mainītis faili ar 16 papildinājumiem un 1 dzēšanām
  1. 16 1
      deltachat-ios/Helper/UIView+Extension.swift

+ 16 - 1
deltachat-ios/Helper/UIView+Extension.swift

@@ -13,7 +13,7 @@ extension UIView {
 		self.layer.borderColor = color.cgColor
 		self.layer.borderWidth = 2
 	}
-	
+
 	func constraintAlignTopTo(_ view: UIView) -> NSLayoutConstraint {
 		return constraintAlignTopTo(view, paddingTop: 0.0)
 	}
@@ -29,6 +29,21 @@ extension UIView {
 			constant: paddingTop)
 	}
 
+	func constraintAlignBottomTo(_ view: UIView) -> NSLayoutConstraint {
+		return constraintAlignBottomTo(view, paddingBottom: 0.0)
+	}
+
+	func constraintAlignBottomTo(_ view: UIView, paddingBottom: CGFloat) -> NSLayoutConstraint {
+		return NSLayoutConstraint(
+			item: self,
+			attribute: .bottom,
+			relatedBy: .equal,
+			toItem: view,
+			attribute: .bottom,
+			multiplier: 1.0,
+			constant: -paddingBottom)
+	}
+
 	func constraintAlignLeadingTo(_ view: UIView) -> NSLayoutConstraint {
 		return constraintAlignLeadingTo(view, paddingLeading: 0.0)
 	}