美文网首页
Xcode11 + iOS13适配

Xcode11 + iOS13适配

作者: 风ai翔 | 来源:发表于2020-09-11 17:28 被阅读0次
参考

https://juejin.im/post/5d85c3fde51d453b7779d604#heading-28
https://www.jianshu.com/p/2ac8dbdcc88f

  • UISearchBar适配
获取textField使用 
#import "UISearchBar+Extension.h"
UITextField *searchField = [_searchBar bp_getSearchTextField];

获取placeholder使用
#import "UITextField+BPAdd.h"
UILabel *placeholderLB = [searchField bp_getPlaceholderLabel];
- (UITextField *)bp_getSearchTextField {
#ifdef __IPHONE_13_0
    if (@available(iOS 13.0, *)) {
        return self.searchTextField;
    }
#endif
    return [self valueForKey:@"_searchField"];
}

- (UILabel *)bp_getPlaceholderLabel {
#ifdef __IPHONE_13_0
    if (@available(iOS 13.0, *)) {
        Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
        UILabel *placeholderLabel = object_getIvar(self, ivar);
        return placeholderLabel;
    }
#endif
    return [self valueForKeyPath:@"_placeholderLabel"];
}
  • presentVC模态弹出页面设置全屏,alertVC可以不设置
UIViewController *vc = [[UIViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[fromController presentViewController:vc animated:YES completion:nil];
  • 推送deviceToken解码兼容处理
if (@available(iOS 13.0, *)) {
    const unsigned char *dataBuffer = (const unsigned char *)deviceToken.bytes;
    NSMutableString *myToken  = [NSMutableString stringWithCapacity:(deviceToken.length * 2)];
    for (int i = 0; i < deviceToken.length; i++) {
        [myToken appendFormat:@"%02x", dataBuffer[i]];
    }
    return (NSString *)[myToken copy];
} else {
    NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"<>"];
    NSString *myToken = [[deviceToken description] stringByTrimmingCharactersInSet:characterSet];
    return [myToken stringByReplacingOccurrencesOfString:@" " withString:@""];
}
  • UITabbar 分割线自定义
if (@available(iOS 13, *)) {
    #ifdef __IPHONE_13_0
    UITabBarAppearance *appearance = [self.tabBar.standardAppearance copy];
    appearance.backgroundImage = [UIImage new];
    appearance.shadowImage = [UIImage imageNamed:@"Dotted_Line"];
    appearance.shadowColor = [UIColor clearColor];
    self.tabBar.standardAppearance = appearance;
    #endif
} else {
    self.tabBar.backgroundImage = [UIImage new];
    self.tabBar.shadowImage = [UIImage imageNamed:@"Dotted_Line"];
}
  • 禁用暗黑模式

Info.plist内全局禁用

  • 状态条设置为黑色有变化
[UIApplication sharedApplication].statusBarStyle = [UIUtility getStatusBarDarkContentStyle];

#pragma mark 获取statusBar的黑色状态枚举值
+ (UIStatusBarStyle)getStatusBarDarkContentStyle {
#ifdef __IPHONE_13_0
    if (@available(iOS 13.0, *)) {
        return UIStatusBarStyleDarkContent;
    } else {
        return UIStatusBarStyleDefault;
    }
#else
    return UIStatusBarStyleDefault;
#endif
}
  • UITextFileds 的 leftView/rightView

不能直接使用UIImageView、UIButton,应该用UIView包一层

相关文章

  • iOS之iOS13适配总结

    前言 随便iOS开发开始更新变成Xcode11,适配iOS13变成了现在的当务之急。 新特性适配 一、新添加的Da...

  • CocoPods更换Ruby源及升级版本

    升级xcode11,项目适配iOS13,MJExtension报错,github上提示需要更新最新版本,使用终端 ...

  • xcode11创建新项目

    1,如果项目不需要适配iOS13以下的机型。xcode11之后,入口放在了SceneDelegate里面。直接使用...

  • xcode11遇到的坑

    苹果出了iOS13,为了适配升级了xcode11,但是升级成功后模拟器运行就报错: Library not fou...

  • Xcode11探索之旅

    在更新到Xcode11、iOS13之后,对原有项目进行适配各种操作。最近需求一个全新的APP,才发现Xcode11...

  • iOS13 快速适配方案汇总

    iOS13后推出暗黑模式,以及一些细节调整,如果不进行适配,用xcode11打包后,app显示会存在显示异常。本文...

  • ios13适配

    iOS13适配 1.私有KVC 在Xcode10上编译不会有问题,但是在Xcode11上编译的会崩溃。并且- (v...

  • iOS13 适配问题 看这一篇就够了

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS 13适配

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS13 适配

    因为2020.4起,所有app必须使用xcode11打包,所以近期处理了一下iOS13的适配工作。这里做一下记录,...

网友评论

      本文标题:Xcode11 + iOS13适配

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