美文网首页
iOS 禁用暗黑模式和缩放问题

iOS 禁用暗黑模式和缩放问题

作者: 弹吉他的少年 | 来源:发表于2019-10-10 15:59 被阅读0次

GitHub地址:KJEmitterView

更新到iOS 13.1.2之后系统开启暗黑模式
App背景和文字相对应的做出了反转

禁用App暗黑模式
快速解决无主题的App问题
在info.plist当中新增如下键值对

<key>UIUserInterfaceStyle</key>
<string>Light</string>
WX20191010-155217@2x.png

iOS13以后 presentViewController 过去的控制器可以滑动和顶部少一截问题

解决方案:
写一个UIViewController的扩展

//
//  UIViewController+KJFullScreen.m
//  Winpower
//
//  Created by 杨科军 on 2019/10/10.
//  Copyright © 2019 cq. All rights reserved.
//

#import "UIViewController+KJFullScreen.h"

@implementation UIViewController (KJFullScreen)

+ (void)load{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        SEL originalSelector = @selector(presentViewController:animated:completion:);
        SEL swizzledSelector = @selector(kj_presentViewController:animated:completion:);
        Class class = [self class];
        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
        if (class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) {
            class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
        } else {
            method_exchangeImplementations(originalMethod, swizzledMethod);
        }
    });
}

- (void)kj_presentViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(void))completion{
    /// presented VC充满全屏
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self kj_presentViewController:vc animated:animated completion:completion];
}

@end
备注:本文用到的部分函数方法和Demo,均来自三方库KJExtensionHandler,如有需要的朋友可自行pod 'KJExtensionHandler'引入即可

iOS13处理介绍就到此完毕,后面有相关再补充,写文章不容易,还请点个小星星传送门

相关文章

网友评论

      本文标题:iOS 禁用暗黑模式和缩放问题

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