iOS 13 適配#
- UIViewController Present 出來的樣式修改
iOS 13 預設的 modalPresentationStyle 是 UIModalPresentationAutomatic,可能不符合我們的要求,改回之前的模式要用 UIModalPresentationFullScreen.
新寫一個 UIViewController 的 Category,改變 modalPresentationStyle 的返回結果
@implementation UIViewController(Category)
- (UIModalPresentationStyle)modalPresentationStyle {
return UIModalPresentationFullScreen;
}
@end
- “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];