4

How can we set dynamic leading and trailing constraints like we give dynamic width and height through percentage of screen size.

Muhammad Umar
  • 131
  • 2
  • 8

2 Answers2

1

Try This
Add below Property in your viewController

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *cnstViewLeading;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *cnstViewTrailing;

Then set Outlet with your leading and Trailing like ......


and

Use Like This

//    replace value whatever you want with 0
    self.cnstViewLeading.constant = 0;
    self.cnstViewTrailing.constant = 0;
Vvk
  • 4,031
  • 29
  • 51
0

You can make outlets of NSLayoutContraint and update its constants according to your need. After updating its constant you need to call view.layoutIfNeeded() Alternatively you can also use multipliers for percentage wise layouts.

Muhammad Zeeshan
  • 2,441
  • 22
  • 33