1、在iOS13中 ,UISegmentedControl默认样式变为白底黑字。去掉白底和黑色底框,以及黑色分割线如下:
if (@available(iOS 13.0, *)) {
//去掉白底
[SegmentedControl setSelectedSegmentTintColor:[UIColor clearColor]];
//去掉底色黑框
[SegmentedControl setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//去掉中间黑色分割线
[SegmentedControl setDividerImage:[UIImage new] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
} else {
// Fallback on earlier versions
}
2、statusBar 在iOS13的取法也变了,还会引起崩溃。
- (UIView *)statusBar{
if (_statusBar == nil){
if (@available(iOS 13.0, *)) {
UIWindow * keyWindow = [ UIApplication sharedApplication ].keyWindow ;
_statusBar= [[UIView alloc ] initWithFrame:keyWindow.windowScene.statusBarManager.statusBarFrame] ;
[keyWindow addSubview:_statusBar ] ;
} else {
// Fallback on earlier versions
_statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
}
}
return _statusBar;
}