First, disable automatic translation of autoResizingMasks to constraints.

Next, add the constraint for the fixed width.

Finally, add the contraint for the fixed height.

Note that I am setting a fixed width of 200 and a fixed height of 300.

Important note: Since we are adding our constraints programmatically, we need to do it in our UIViewController’s method:

(as stated in
Also, remember to call [super updateViewConstraints] when implementing the above method.

There is another way to define fixed width and height using constraints programmatically.
We can use NSLayoutAttributes to define this.


Happy Goals for iOS

Happy Goals for iOS

Want an app to help you track and achieve your goals, without the complex stuff, saving you from headaches? Checkout Happy Goals - Habits & Goals Tracker now in the App Store! Happy Goals has been featured in the App Store in over 32 countries. Start now, better late than never!


Thank you!

%d bloggers like this: