美文网首页iOS UI
iOS13 App适配

iOS13 App适配

作者: 修正 | 来源:发表于2019-10-18 14:53 被阅读0次

1. 设置不响应黑暗模式

Info.plist中添加以下代码

    <key>UIUserInterfaceStyle</key>
    <string>Light</string>
Info.plist

2. 字体适配

iOS13中获取系统字体的fontName,得到的是并没有什么用的 romannewtime字体.
建议使用

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(UIFontWeight)weight API_AVAILABLE(ios(8.2));

// Suggested values for use with UIFontWeightTrait, and UIFont's systemFontOfSize:weight:
// Beware that most fonts will _not_ have variants available in all these weights!
UIKIT_EXTERN const UIFontWeight UIFontWeightUltraLight API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightThin API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightLight API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightRegular API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightMedium API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightSemibold API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightBold API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightHeavy API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightBlack API_AVAILABLE(ios(8.2));

3. 弹出样式

/*
 Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
 If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but system-provided subclasses may resolve UIModalPresentationAutomatic to other concrete presentation styles. Participation in the resolution of UIModalPresentationAutomatic is reserved for system-provided view controllers.
 Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
 */
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(ios(3.2));

因此我们的方案是在BaseViewController中,指定样式为全屏,两个时机:

  • 初始化的时候
  • 调用弹起时
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        self.modalPresentationStyle = UIModalPresentationFullScreen;
    }
    return self;
}

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^ __nullable)(void))completion {
    if (@available(iOS 13.0, *)) {
        if (viewControllerToPresent.modalPresentationStyle == UIModalPresentationPageSheet) {
            viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
        }
    }

    [super presentViewController:viewControllerToPresent animated:flag completion:completion];
}

4. UITabBar样式

  • 字体颜色异常(显示蓝色)
//iOS 13中需设置
if (@available(iOS 13.0, *)) {
    self.tabBar.tintColor = Red_COLOR;
    self.tabBar.unselectedItemTintColor = 66_66_66_COLOR;
}
  • Gif显示异常(灰块)
// 需要将gif的每一帧设置为 UIImageRenderingModeAlwaysOriginal 
    if (@available(iOS 13.0, *)) {
        NSArray *sourceInsideImages = [tabImage images];
        NSMutableArray *insideImages = [[NSMutableArray alloc] initWithCapacity:0];
        for (UIImage *sourceImage in sourceInsideImages) {
            UIImage *insideImage = [sourceImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            [insideImages addObject:insideImage];
        }
        tabImage = [UIImage animatedImageWithImages:insideImages duration:tabImage.duration];
    }
  • 隐藏头部线条
        UITabBarAppearance *appearance = tabBar.standardAppearance.copy;
        appearance.shadowColor = [UIColor clearColor];
        appearance.shadowImage = [UIImage new];
        tabBar.standardAppearance = appearance;

相关文章

  • iOS13适配研究

    iOS13今年秋季会发布,最近深入研究了下公司APP适配iOS13的注意点,适配如下。 1.由于Xcode10移除...

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

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

  • iOS 13适配

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

  • ios 不想适配ios13暗黑模式怎么办? Xcode10打包适

    前言:ios13可以设置暗黑模式,即浅色和深色,但是app如果适配的话需要做很多工作,比如暗黑图片等,如果不想适配...

  • iOS13 App适配

    1. 设置不响应黑暗模式 在Info.plist中添加以下代码 2. 字体适配 iOS13中获取系统字体的font...

  • iOS13 App适配

    前言 随着iOS系统的更新迭代,作为iOS开发者也应该跟随其脚步, 本篇文章出于开发者的角度,量身打造,绕过新系统...

  • iOS13 暗黑模式的适配(Dark Mode)

    尽管iOS13已经推出了大半年多的时间,但是依旧还是有不少APP还未适配iOS13。对此,苹果公司再次给开发者们发...

  • iOS暗黑模式(Dark Mode)适配之WKWebview与轮

    0、前言 随着iOS13的普及,大多数的APP都已经适配了暗黑模式,网络上关于暗黑模式适配的文章也很多,基本看几篇...

  • iOS13 AppDelegate、SceneDelegate兼

    如果不适配就会导致iOS13以前的系统无法正确加载UIWindow而导致APP黑屏问题,如下是保留SceneDel...

  • 暗黑模式开发

    iOS13暗黑模式适配(项目开发版) iOS 13 DarkMode 暗黑模式 IOS 暗黑模式适配---基础适配

网友评论

    本文标题:iOS13 App适配

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