1.導航欄顯示
iOS15中,蘋果對導航欄的性能做了優化,默認情況下,如果導航欄與視圖沒有折疊,導航欄的背景透明,如果系統檢測到有重疊的話,會變成毛玻璃的效果
這個效果會影響到一種情況,就是當前頁面導航欄隱藏,然后下一個頁面導航欄顯示的時候,進行push或者從下一個頁面pop時,導航欄處動畫會有異樣
我的解決辦法
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
[appearance setShadowImage:[[UIImage alloc] init]];
[appearance setBackgroundColor:TAD_THM.navigationBackgroundColor];
// 隱藏分割線 設置一個透明或者純色的圖片 設置nil 或者 [UIImage new]無效
[appearance setBackgroundImage:[UIImage zt_imageWithPureColor:[UIColor whiteColor]]];
[appearance setShadowImage:[UIImage zt_imageWithPureColor:[UIColor whiteColor]]];
[[UINavigationBar appearance] setScrollEdgeAppearance: appearance];
}
+ (UIImage *)zt_imageWithPureColor:(UIColor *)color {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(3, 3), NO, [UIScreen mainScreen].scale);
UIBezierPath* p = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 3, 3)];
[color setFill];
[p fill];
UIImage* img = UIGraphicsGetImageFromCurrentImageContext();
return img;
}
+ (UIImage *)zt_imageWithPureColor:(UIColor *)color size:(CGSize )size{
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
UIBezierPath* p = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, size.width, size.height)];
[color setFill];
[p fill];
UIImage* img = UIGraphicsGetImageFromCurrentImageContext();
return img;
}
2.UITableView Section的header增加默認間距
解決辦法
if (@available(iOS 15.0, *)) {
table.sectionHeaderTopPadding = 0;
}