Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在视图中重叠UIButton和UIImage?_Ios_Objective C_Uiimageview_Uibutton - Fatal编程技术网

Ios 如何在视图中重叠UIButton和UIImage?

Ios 如何在视图中重叠UIButton和UIImage?,ios,objective-c,uiimageview,uibutton,Ios,Objective C,Uiimageview,Uibutton,我想与UIImageView和UIButton重叠,如下图所示 ui图像视图位于两个ui按钮后面 如果我将UIImageView放在这两个按钮的后面,如何确保UIImageView不会阻挡UIImageView 提前感谢。您只需启用UIImageView的用户交互userInteractionEnabled 它的默认值为“否”,设置“是”将使事件变为ui按钮 因此,在“自视图”上,您可以添加“图像视图”和“图像视图”按钮。为了确保您的按钮可见并且捕捉到事件,您可以使用将SubviewTofro

我想与
UIImageView
UIButton
重叠,如下图所示

ui图像视图
位于两个
ui按钮
后面

如果我将
UIImageView
放在这两个
按钮的后面,如何确保
UIImageView
不会阻挡
UIImageView


提前感谢。

您只需启用
UIImageView
的用户交互
userInteractionEnabled

它的默认值为“否”,设置“是”将使事件变为
ui按钮


因此,在“自视图”上,您可以添加“图像视图”和“图像视图”按钮。

为了确保您的按钮可见并且捕捉到事件,您可以使用
将SubviewTofront

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