美文网首页
iOS13适配汇总

iOS13适配汇总

作者: Lorne_coder | 来源:发表于2019-10-09 09:55 被阅读0次

    1、deviceToken的数据结构改变,需要更改取值方法(参考友盟):

    if (![deviceToken isKindOfClass:[NSData class]]) return;
    const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
    NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
                          ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
                          ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
                          ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
    self.devToken = hexToken;
    NSLog(@"deviceToken:%@", self.devToken);
    

    2、设置状态栏的背景颜色,原有的方式用到了KVC的valueForKey:方法来获取系统API的私有属性,程序会crash,我的做法是这样的:

    /**设置状态栏背景颜色*/
    + (void)setStatusBarBackgroundColor:(UIColor *)color control:(UIViewController *)control
    {
        // iOS13 之前
        /*
        UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
        if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
            statusBar.backgroundColor = color;
        }
         */
        
        // iOS13 之后
        control.navigationController.navigationBar.barTintColor = color;
    }
    
    

    3、新增设备型号:苹果官网设备型号说明,如果项目中用到了这个,需要把新增的设备型号加进去!

    相关文章

      网友评论

          本文标题:iOS13适配汇总

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