iOS 13.0适配及app崩溃问题解决

2019-11-15  本文已影响0人  Jesscia_Liu

一. presentView样式默认改变

- (UIModalPresentationStyle)modalPresentationStyle {
        return UIModalPresentationFullScreen;
}

二. 有些KVO属性不能直接使用,会导致app启动崩溃

1._placeholderLabel.textColor

//13.0以前可用
        [searchField setValue:MLHexColor(0x8FA2C2) forKeyPath:@"_placeholderLabel.textColor"];

//13.0及以后替换方法
        searchField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:22],NSForegroundColorAttributeName:[UIColor redColor]}];

2. statusBarWindow的statusBar

    if (@available(iOS 13.0, *)) {
        
        UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager;

        if([statusBarManager respondsToSelector:@selector(createLocalStatusBar)]) {

            UIView *localStatusBarView= [statusBarManager            performSelector:@selector(createLocalStatusBar)];

            UIView *statusBarView = [localStatusBarView performSelector:@selector(statusBar)];


           //根据当前状态栏的类型,重置状态栏颜色(否则截屏出来的都是默认颜色)
            UIColor *statusBarColor = color;

            UIStatusBarStyle statusBarStyle = self.preferredStatusBarStyle;//获取当前视图控制器的状态栏类型

            if(statusBarStyle ==UIStatusBarStyleLightContent) {
                [statusBarView performSelector:@selector(setForegroundColor:)withObject:statusBarColor];

            }
        }else{
            UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
            if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
                statusBar.backgroundColor = color;
            }
        }

上一篇下一篇

猜你喜欢

热点阅读