PHP Web Dev 101
PHP Web Dev 101

Reputation: 555

Why is the UIButton larger than I set it

I have a UIButton in my Xcode project that has constraints(see image #3). The height and width are both set to 80 but when I run the project it looks like bigger than what it is set to. (See image #2)

In the .m file, it is set 80x80 as well (objective-c)

openMenu.layer.frame = CGRectMake(self.view.center.x - 27, self.view.frame.size.height - 80, 80, 80);

It should look like:

Image #1

enter image description here

Image #2

enter image description here

Image #3

enter image description here

Note: Those are the actual sizes (it is fit to scale)

Why is it big like image #2 and how do I fix it so it stay 80x80 like image #1?

Upvotes: 0

Views: 139

Answers (3)

JAY RAPARKA
JAY RAPARKA

Reputation: 1326

trying to add hieght and width fix constraint hope this will help.

Upvotes: 1

kriOSDeveloper
kriOSDeveloper

Reputation: 101

This will resize the button image to your desired size adding margins to it.

[openMenu setImageEdgeInsets:UIEdgeInsetsMake(25, 25, 25, 25)];

Upvotes: 0

bsarr007
bsarr007

Reputation: 1964

You should also set width and height constrains in Interface Builder.

Upvotes: 1

Related Questions