I have a UIView in a UIViewController in Storyboard. There is a UIImageView inside it.
I want to increase the height of UIView programmatically:
CGRect frame = headerV.frame;
frame.size.height = 100;
headerV.frame = frame;
The problem is it also stretch the UIImageView. If I do not want to add the UIImage programmatically, how can I solve this problem?
Option 1 – using resizing flags
A) Disable autoresizesSubviews on
headerV.autoresizesSubviews = NO.or
B) Setup the correct autoresizingMask on your imageView. Do this:
imageView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin,if it should stick to the top (or smth. else – whatever setup you want)
Option B – autolayout
setup your autolayout correspondingly ,)
(PS: You can do all of this in interfaceBuilder or within the code.)