I want to overlap with UIImageView
and UIButton
like the following picture.
The UIImageView
is behind the two UIButton
.
If I put the UIImageView
behind these two Button
, how can I sure the UIButton
will not barricaded by the UIImageView
?
Thanks in advance.
In order to make sure your buttons are visible and events are caught you can use bringSubviewToFront
.
UIImageView *myImageView = //..alloc, init;
UIButton *button1 = //..alloc, init;
UIButton *button2 = //..alloc, init;
[self.view addSubview:myImageView];
[self.view addSubview:button1];
[self.view addSubview:button2];
[self.view bringSubviewToFront:button1];
[self.view bringSubviewToFront:button2];
You just need to enable the user interaction userInteractionEnabled
of UIImageView
.
Default value of it is NO, and setting YES will paas down the event to UIButton
.
So structure wise on self view you can add image view and on image view buttons can be added.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.