How do I programmatically change the size a UIImageView that was created on storyboard with autolayout?

I have an outlet to a UIImageView hooked up from my storyboard to my header file. I am trying to alter the frame of the UIImageView programmatically from my implementation file. I have done the following:

-(void)viewDidLoad{
    [super viewDidLoad];
        if (IS_IPHONE_5) {
            someImageView.frame = CGRectMake(someImageView.frame.origin.x, someImageView.frame.origin.y, someImageView.frame.size.width - 50, someImageView.frame.size.height - 50);
    }
}

No matter what I change my width and height to it doesn't seem to change. Could it be that I am using autolayout and have constraints hooked up to the imageView? If so, how do I override these to change the image view's height and width?

Is there a simpler way to do this just from the storyboard?

Thanks in advance.

Upvotes: 1

Views: 782

Answers (1)

Rob
Rob

Reputation: 438287

You might want to reevaluate the constraints you set up in IB. Make sure you don't have width or height constraints, but instead top/bottom/leading/trailing constraints. Then you probably don't have to do anything programmatically. But if you must resize programmatically, create IBOutlet references to the constraints in the storyboard, and then you can adjust the constant property of the constraint. But don't attempt to change the frame if you're using constraints.

Upvotes: 3

Related Questions