Question

The action sheet naturally greys out the background view a little bit, but it isn't really noticeable. I want to make it much darker.

Also, how do I make it so you cannot click anywhere else? Right now if you click outside of the action sheet, it makes the action sheet go away. I want that to not happen - you should have to push the "cancel" button to make the action sheet go away.

Was it helpful?

Solution

You may try something like this:

@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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top