1

I am trying to alter the width and height of an UIImageView object but for some reason I can't.

This is the code I used:

-(void)setMenuImages
{ 
        self.menuImageButton.image=[UIImage imageNamed:@"myimage.jpg"]; 
        self.menuImageButton.frame=CGRectMake(0,0,20,150); 
}

What am I doing wrong? The (UIImageView) menuImageButton is not created programmatically, but from storyboard interface with initial leading, trailing, width and height constraints.

Student
  • 418
  • 1
  • 4
  • 17

1 Answers1

1

You can self. menuImageButton.translatesAutoresizingMaskIntoConstraints = false in viewDidLoad and remove their constraints or you can add those constraints as IBOutlets and change them like

self.imageWidthConstraint.constant = 20;
self.imageHeightConstraint.constant = 150;

UPDATE

To declare constraints in your header file you need to select those constrains and right click drag to the .h file as show in the gif

enter image description here

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55