简体   繁体   中英

How to make a clearColor for superview on iOS 8

Help please. How to make a clear Color for modal View on iOS 8, write so

self.view.superview.backgroundColor = [UIColor clearColor];

Work on iOS 7 but not on iOS 8. It becomes clear but not completely

在此处输入图片说明

尝试像这样更改alpha值:-

[[UIColor clearColor] colorWithAlphaComponent:0.6];

If you set background color for the main UIViewController view, you need to setup it before:

- (void)setupModalPresentationStyle
{
    self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
        self.modalPresentationStyle = UIModalPresentationOverFullScreen;
    }
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    [self setupModalPresentationStyle];
}

And when you present this UIViewController, you need to setup current presenting UIViewController:

- (void)doneButtonTap:(id)sender {
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentViewController:detailsViewController animated:YES completion:nil];
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM