Tuesday, 12 December 2017

Dynamic Constraint



A. First set static constraint of a view like - Button, Image, UIView etc.

1. Select a constraint (Leading, Top, Trailing, Bottom)  and drag to View Controller IBOutlet

Code -  @IBOutlet weak var leadingConstraint: NSLayoutConstraint!

2. Constraint :

Code - leadingConstraint.constant = 100

3. Check constraint available

Code - leadingConstraint.isActive

4.


22

No comments:

Post a Comment

Different type to create constraint programmatically

Do you plan to have a squared  UIView  of  width: 100  and  Height: 100  centered inside the  UIView of an  UIViewController ? If so, y...