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
2010-08-11 21:51:16
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
2010-08-11 22:00:47
I added some padding. How about that?
Matt Williamson
2010-08-11 23:25:20
A:
Just make a custom button with an image-view in Interface-Builder.
DailyDoggy
2010-08-11 22:14:48