Displaying UIImageViews with label/buttons in them
I need to display images with buttons in them. The number of images displayed depends on how many objects there in the array. I'm able to get a layout of my images with the help of - laying out images i开发者_Go百科n UIScrollView automatically
However, I need to have a label and buttons in my images.
e.g
_____ _____
|a oo| |a oo|
| | | |
| | | |
|_____| |_____|
_____ _____
|a oo| |a oo|
| | | |
| | | |
|_____| |_____|
_____ _____
|a oo| |a oo|
| | | |
| | | |
|_____| |_____|
(a=label, o=buttons)
Will adding another UIView with my image+button layout design to my main view work? If so, how do I go about this? Thanks in advance (:
if you add a button inside a UIImageView as subview, the button wont respond to touch events. So use UIView instead of imageview to add buttons and labels. You can give background image for that view using
myView.backgroundColor= [[UIColor alloc]initWithPatternImage:
[UIImage imageNamed:@"myimage.png"]];
Simply add the subview to the images:
[anImage addSubview:someButtonOrLabelView];
精彩评论