views:

114

answers:

2

I have a UIButton over a UIImageView. I want the button to adjust its size to fit the imageview. I tried a few different ways but can't get it. Anyone know how to do this?

+1  A: 

You can add some padding like this:

NSInteger padding = 10;
CGRect newFrame = myImageView.bounds;
newFrame.origin.x += padding / 2.0;
newFrame.origin.y += padding / 2.0;
newFrame.size.width -= padding;
newFrame.size.height -= padding;
myButton.frame = newFrame;
Matt Williamson
sorry, i set the content mode of the uiimageview to aspect fit. so there's some blank area around the edge of the picture. so i guess what i need to know is how to get the size of the imageview minus the blank area caused by the aspectFit.
marty
I added some padding. How about that?
Matt Williamson
A: 

Just make a custom button with an image-view in Interface-Builder.

DailyDoggy