iOS 13 平臺(tái)運(yùn)行崩潰
輸出臺(tái)報(bào):
Terminating app due to uncaught exception 'NSGenericException', reason: ........
可能就是某條私有屬性被禁用了接奈。
比如以下例子崩潰日志如下:
Terminating app due to uncaught exception 'NSGenericException',
reason: 'Access to _UIBarBackground's _backgroundEffectView ivar is prohibited.
This is an application bug'
通過(guò)訪問(wèn)導(dǎo)航欄私有視圖 _backgroundEffectView 并設(shè)置其透明度來(lái)達(dá)到導(dǎo)航欄透明的效果技即,這條私有屬性被禁用了屡江,UIView *barBackgroundView = self.navigationBar.subviews.firstObject; 可以直接拿到設(shè)置。
- (void)setNavigationBarBackgroundAlpha:(CGFloat)alpha {
UIView *barBackgroundView = self.navigationBar.subviews.firstObject;
if (@available(iOS 13.0, *)) {
barBackgroundView.alpha = alpha;
return;
}
// 處理底部分割線
UIView *shadowView = [barBackgroundView valueForKey:@"_shadowView"];
shadowView.hidden = (alpha < 1.0);
// 處理背景
if (self.navigationBar.isTranslucent) {
if (@available(iOS 10.0, *)) {
UIView *backgroundEffectView = [barBackgroundView valueForKey:@"_backgroundEffectView"];
backgroundEffectView.alpha = alpha;
} else {
UIView *adaptiveBackdrop = [barBackgroundView valueForKey:@"_adaptiveBackdrop"];
adaptiveBackdrop.alpha = alpha;
}
} else {
barBackgroundView.alpha = alpha;
}
}
另外:
如果使用到藍(lán)牙通訊
需要在info.plist里面添加
NSBletoothAlwaysUsageDescription
和 Privacy - Bluetooth Peripheral Usage Description