1

I have a UIView on my UIViewController. I set width and height using Editor -> Pin -> Width/Height. Also i created IBOutlet of these constraints to change widht and height programatically. I worte code

in .h file

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *viewWidth;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *viewHeight;

in .m file

self.viewWidth.constant = 480;
self.viewHeight.constant = 644;

but still its not changing the width and height of view. Am i missing something? Thanks in advance.

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
Bhushan B
  • 2,470
  • 4
  • 26
  • 38

2 Answers2

0

After updating the constants, you need to invoke -layoutIfNeeded or -setNeedsUpdateConstraints.

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
0

Here a solution to update constants of constraints programmatically without IBOutlet.

Hide autolayout UIView : How to get existing NSLayoutConstraint to update this one

Community
  • 1
  • 1
Damien Romito
  • 9,801
  • 13
  • 66
  • 84