I know to change auto layout constraints with IBOutlet NSLayoutConstraint * xyz;
I am doing with this code:
Add constraints with this code
NSLayoutConstraint *btnbottomConstraint = [NSLayoutConstraint constraintWithItem: currentview attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0f constant:sheight];
[supperView addConstraint:btnbottomConstraint];
Get constraints with this code
NSArray * arrConstarint=btnSubbmit.constraints;
for (NSLayoutConstraint * constraint in arrConstarint)
{
if (constraint.firstAttribute==NSLayoutAttributeHeight)
{
constraint.constant=self.maxHeight;
}
else if (constraint.firstAttribute==NSLayoutAttributeWidth)
{
constraint.constant=self.maxWidth;
}
}
when i get constraints of view then arrConstarint.count is 0, please help me where i wrong.Thanks in advance.
Try
[supperView addConstraint:btnbottomConstraint];
to
[currentView addConstraint:btnbottomConstraint];
height and width will be added to view not with respect to superview. Let me know if it you need further help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With