1、UIViewController切换方式modalPresentationStyle
iOS13默认UIModalPresentationAutomatic模式,不符合我们的需求。改回之前的模式要用UIModalPresentationFullScreen。
vc.modalPresentationStyle = UIModalPresentationFullScreen;
但是,问题来了,项目里vc太多,而且因为接入了多家SDK,viewController并没有一个相同父VC,全局改太费劲了。
解决方案:
在appDelegate中实现了ViewController的分类,改变了modalPresentationStyle的值完美解决。
@implementation UIViewController(modalPresentationStyle)
- (UIModalPresentationStyle)modalPresentationStyle{
return UIModalPresentationFullScreen;
}
@end
2、"NSGenericException" - reason: "Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug"
设置TextFiled的默认文字颜色在iOS13 Crash。
[textfield setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
查了一下,帖子挺多的,解决方案:
Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
UILabel *placeholderLabel = object_getIvar(textField, ivar);
placeholderLabel.textColor = [UIColor whiteColor];
记得加头文件
#import
3、去除TabBar黑线
iOS13 新增api UITabBarAppearance
if (@available(iOS 13.0, *)) {//去除iOS13的TabBarg黑线
UITabBarAppearance* tabbarAppearance =self.tabBar.standardAppearance;
tabbarAppearance.backgroundImage = [self imageWithColor:[UIColor clearColor] size:self.tabBar.size];
tabbarAppearance.shadowImage = [self imageWithColor:[UIColor clearColor] size:self.tabBar.size];
self.tabBar.standardAppearance = tabbarAppearance;
} else {
self.tabBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:self.tabBar.size];
self.tabBar.shadowImage = [self imageWithColor:[UIColor clearColor] size:self.tabBar.size];
}
注: [self imageWithColor:[UIColor clearColor] size:self.tabBar.size]; 为根据控件size生成的纯色图片,代码如下
#pragma mark - 给出颜色值,制作纯色图片
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
if (!color || size.width <=0 || size.height <=0) return nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size,NO, 0);
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}