如何使操作表在调用时使周围视图变暗?



操作表自然地使背景视图变灰,但并不明显。我想让它更暗一些。

还有,我怎么做才能让你不能点击其他任何地方?现在如果你点击动作表单外面,它会让动作表单消失。我不希望这种情况发生——你应该按下"取消"按钮,让动作表单消失。

您可以尝试这样做:

@property (nonatomic, strong) UIView *shadowView; 
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
    if (!self.shadowView)
    {
        self.shadowView = [[UIView alloc]initWithFrame:self.view.bounds];
        self.shadowView.backgroundColor = [UIColor colorWithRed:(42.0/255.0) green:(42.0/255.0) blue:(42.0/255.0) alpha:1.0];
        self.shadowView.alpha = 0.7;
        [self.view addSubview:self.shadowView];
    }
    else
    {
        self.shadowView.alpha = 0.7;
    }
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    self.shadowView.alpha = 0.0;
}

最新更新