今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

iOS 13 适配

iOS 13 适配#

转自iOS 13 采坑记录
iOS 13 适配总结

  1. UIViewController Present 出来的样式修改

iOS 13 默认的 modalPresentationStyle 是 UIModalPresentationAutomatic,可能不符合我们的要求,改回之前的模式要用 UIModalPresentationFullScreen.

新写一个 UIViewController 的 Category,改变 modalPresentationStyle 的返回结果

@implementation UIViewController(Category)

- (UIModalPresentationStyle)modalPresentationStyle {
    return UIModalPresentationFullScreen;
  }

@end
  1. “NSGenericException” -reason: “Accress to UITextField’s _placeholderLabel ivar is prohibited.”
    设置 TextField 的 placeholder 颜色在 iOS 13 Crash,即下面的方法会崩溃
[textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];

修改:

#import <objc/runtime.h>

Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
UILabel *placeholderLabel = object_getIvar(textField, ivar);
placeholderLabel.textColor = [UIColor whiteColor];
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.