美文网首页
iOS 13.0适配及app崩溃问题解决

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

作者: Jesscia_Liu | 来源:发表于2019-11-15 16:57 被阅读0次

一. presentView样式默认改变

  • 若要用回以前全屏需要在对应present的controller中添加如下语句
- (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;
            }
        }

相关文章

网友评论

      本文标题:iOS 13.0适配及app崩溃问题解决

      本文链接:https://www.haomeiwen.com/subject/tqusictx.html