Iphone 如何创建具有透明视图和可触摸背景视图的视图?

Iphone 如何创建具有透明视图和可触摸背景视图的视图?,iphone,ios,objective-c,view,Iphone,Ios,Objective C,View,我需要创建一个这样的视图。其中,类似于操作表的视图是添加在viewcontroller上的子视图。这不是真正的行动计划。 我想让覆盖视图后面的控件也可以触摸操作表按钮。 有人能建议怎么做吗 类似这样: UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Test Action Sheet" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTit

我需要创建一个这样的视图。其中,类似于操作表的视图是添加在viewcontroller上的子视图。这不是真正的行动计划。 我想让覆盖视图后面的控件也可以触摸操作表按钮。 有人能建议怎么做吗

类似这样:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Test Action Sheet" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Home",@"iPhone", nil];
    [actionSheet showInView:self.navigationController.view];

在所有视图的前面取一个
UIImageView
,然后将Alpha设置为类似于下面的内容

[imgBackShadow setAlpha:0.9];// set yourImage name instead of imgBackShadow
// Also set different value to Alpha with your requirement
[imgBackShadow setUserInteractionEnabled:NO];// set yourImage name instead of imgBackShadow
[imgBackShadow setHidden:YES];
首先将
setHidden
设置为
YES
,当您想打开
UIActionSheet
时,只需将
setHidden
设置为
NO
即可,还可以将属性
setUserInteractionEnabled
设置为
NO
,如下所示

[imgBackShadow setAlpha:0.9];// set yourImage name instead of imgBackShadow
// Also set different value to Alpha with your requirement
[imgBackShadow setUserInteractionEnabled:NO];// set yourImage name instead of imgBackShadow
[imgBackShadow setHidden:YES];
示例:当您想打开
UIActionSheet
时,请使用下面的代码

[imgBackShadow setHidden:NO];
[self.view bringSubviewToFront:imgBackShadow];
[self.view bringSubviewToFront:yourActionSheet];
当您想关闭
UIActionSheet
时,只需像下面那样隐藏该图像

[imgBackShadow setAlpha:0.9];// set yourImage name instead of imgBackShadow
// Also set different value to Alpha with your requirement
[imgBackShadow setUserInteractionEnabled:NO];// set yourImage name instead of imgBackShadow
[imgBackShadow setHidden:YES];

希望对您有所帮助。

我的操作表是一个自定义视图,我使用了操作表上方视图上的按钮。禁用用户交互和设置alpha.7后,我的工作正常。

您的问题可能与此类似。您可以看到这一点,您还需要添加一个代理UIActionSheetDelegate