今是昨非

今是昨非

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

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];
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。