开发者

Displaying UIImageViews with label/buttons in them

开发者 https://www.devze.com 2023-03-16 03:17 出处:网络
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 -

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];

0

精彩评论

暂无评论...
验证码 换一张
取 消