【问题标题】:How to make a clearColor for superview on iOS 8如何在 iOS 8 上为 superview 制作 clearColor
【发布时间】:2014-12-13 15:22:10
【问题描述】:

请帮忙。如何在iOS 8上为模态视图制作清晰的颜色,这样写

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

在 iOS 7 上工作,但在 iOS 8 上不工作。变得清晰但不完全

【问题讨论】:

    标签: ios objective-c ios8 modalviewcontroller


    【解决方案1】:

    尝试像这样更改 alpha 值:-

    [[UIColor clearColor] colorWithAlphaComponent:0.6];
    

    【讨论】:

    • 是的,还有清晰的颜色。视图可以是透明的,但超级视图不是。
    • self.view.superview = nil;错误 - 分配给只读属性
    • 好的,所以不允许,但你可以尝试将你的子视图大小设置为与 superview 相同。
    【解决方案2】:

    如果你为 UIViewController 主视图设置了背景颜色,你需要在之前设置它:

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

    当你呈现这个 UIViewController 时,你需要设置当前呈现的 UIViewController:

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

    【讨论】:

    • 这段代码在哪里写? self.modalPresentationStyle = UIModalPresentationCurrentContext; [self presentViewController:detailsViewController 动画:YES 完成:nil];
    • 展示模态视图控制器的地方
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多