iOS - 13系统下关于模态、UITextField、UISegmentedControl适配

1.系统模态样式的改变,iOS13之后,模态样式变成了卡片样式,如果想继续全屏的话,需要手动设置为

vc.modalPresentationStyle = UIModalPresentationFullScreen;

2.UITextField的leftView以及rightView,以及KVC方式访问私有变量崩溃问题

(1)UITextField leftView,如果添加的视图是UIView那就没事,如果是Label或者其他的btn类的的需要外包一层View,可以写个分类,如下

//.h
#import 

@interface UITextField (Extension)

@property (nonatomic ,strong) UIView *customLeftView;

@property (nonatomic ,strong) UIView *customRihgtView;

@end
//.m
#import "UITextField+Extension.h"

@implementation UITextField (Extension)

-(void)setCustomLeftView:(UIView *)customLeftView{
    
    UIView *view = [[UIView alloc]initWithFrame:customLeftView.frame];
    [view addSubview:customLeftView];
    
    self.leftView = view;
}

-(UIView *)customLeftView{
    return self.leftView;
}


-(void)setCustomRihgtView:(UIView *)customRihgtView{
    
    UIView *view = [[UIView alloc]initWithFrame:customRihgtView.frame];
    [view addSubview:customRihgtView];
    
    self.rightView = view;
    
}

-(UIView *)customRihgtView{
    
    return self.rightView;
}

@end

(2)KVC方式修改placeholderLabel问题导致的崩溃,更新Xcode10后苹果不允许再以这种方式去访问修改私有变量,可以采用获取类的方式去修改,亲测可行

//.h
#import 

@interface UITextField (Extension)

@property (nonatomic, strong, readonly) UILabel *placeLabel;

@end

//.m
#import "UITextField+Extension.h"

@implementation UITextField (Extension)

- (UILabel *)placeLabel{
    
    Ivar ivar =  class_getInstanceVariable([self class], "_placeholderLabel");
    UILabel *placeholderLabel = object_getIvar(self, ivar);
    
    return placeholderLabel;
    
}

@end

3.UISegmentedControl 的变化,如果觉得白底黑字不是你们想要的,就参考这位同学写的
https://www.jianshu.com/p/63014bd17264)

你可能感兴趣的:(iOS - 13系统下关于模态、UITextField、UISegmentedControl适配)