美文网首页
iOS13适配

iOS13适配

作者: 靠北的北 | 来源:发表于2019-09-26 15:49 被阅读0次

1、TabBar色值在Present VC之后会恢复系统默认值,解决如下:

if (IOS13_OR_LATER) {
            [[UITabBar appearance] setUnselectedItemTintColor:themeColor];
            [[UITabBar appearance] setTintColor:themeCustomColor];
        }else{
            [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:themeCustomColor} forState:UIControlStateSelected];
            [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:themeColor} forState:UIControlStateNormal];
        }

2、Dark Mode
不支持

// info.plist中添加
User Interface Style [string] Light

如果使用Apple默认[UIColor WhiteColor]等设置颜色需要注意,如果不设置上述不支持dark mode则在对应模式下,会改变相关颜色。


3、Present VC
iOS13中默认Present为半屏弹出,触摸向下可关闭,如果想要保持iOS12及以前方式,则可以使用Category。

UIViewController+K_Utils.h

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIViewController (K_Utils)
/**
Whether or not to set ModelPresentationStyle automatically for instance, Default is [Class K_automaticallySetModalPresentationStyle].
@return BOOL
*/
@property (nonatomic, assign) BOOL K_automaticallySetModalPresentationStyle;

/**
 Whether or not to set ModelPresentationStyle automatically, Default is YES, but UIImagePickerController/UIAlertController is NO.
 @return BOOL
 */
+ (BOOL)K_automaticallySetModalPresentationStyle;
@end

NS_ASSUME_NONNULL_END

UIViewController+K_Utils.m

#import "UIViewController+K_Utils.h"
#import <objc/runtime.h>

static const char *K_automaticallySetModalPresentationStyleKey;

@implementation UIViewController (K_Utils)
+ (void)load {
    Method originAddObserverMethod = class_getInstanceMethod(self, @selector(presentViewController:animated:completion:));
    Method swizzledAddObserverMethod = class_getInstanceMethod(self, @selector(K_presentViewController:animated:completion:));
    method_exchangeImplementations(originAddObserverMethod, swizzledAddObserverMethod);
}

- (void)setK_automaticallySetModalPresentationStyle:(BOOL)K_automaticallySetModalPresentationStyle {
    objc_setAssociatedObject(self, K_automaticallySetModalPresentationStyleKey, @(K_automaticallySetModalPresentationStyle), OBJC_ASSOCIATION_ASSIGN);
}

- (BOOL)K_automaticallySetModalPresentationStyle {
    id obj = objc_getAssociatedObject(self, K_automaticallySetModalPresentationStyleKey);
    if (obj) {
        return [obj boolValue];
    }
    return [self.class K_automaticallySetModalPresentationStyle];
}

+ (BOOL)K_automaticallySetModalPresentationStyle {
    if ([self isKindOfClass:[UIImagePickerController class]] || [self isKindOfClass:[UIAlertController class]]) {
        return NO;
    }
    return YES;
}

- (void)K_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
    if (@available(iOS 13.0, *)) {
        if (viewControllerToPresent.K_automaticallySetModalPresentationStyle) {
            viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
        }
        [self K_presentViewController:viewControllerToPresent animated:flag completion:completion];
    } else {
        // Fallback on earlier versions
        [self K_presentViewController:viewControllerToPresent animated:flag completion:completion];
    }
}

相关文章

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

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

  • iOS 13适配

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

  • 暗黑模式开发

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

  • iOS13适配更新总结

    前言: iOS13的API的变动和适配问题,我从新特性适配、API 适配、方法弃用、工程适配、SDK 适配、其他问...

  • iOS13适配研究

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

  • iOS13适配

    参考: iOS13 适配踩坑 - 持续更新 iOS 13 适配要点总结 iOS 13 适配要点总结 1、prese...

  • iOS13适配(更新中)

    对于iOS13适配汇总以及遇到的问题注意:以下适配内容,必须适配的会以"必须"标出 1. Dark Model(必...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

  • 2019--09iOS13适配

    iOS13适配iOS13更新后对Ai定损、一车一件项目进行适配 做了一下调查 1 2 3 4 5 6 目前调研的只...

网友评论

      本文标题:iOS13适配

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