1. Background color of Tabbar and NavicationBar
Problem: The background color of the navigation bar fails when upgrading from ios14 to ios15
Cause: the color setting method is disabled in ios15
NavigationBar, Tabbar, navigationBar,tabbar, navigationBar, Tabbar, navigationBar, Tabbar There is no use UINavigationBarAppearance about navigation bar Settings and UITabBarAppearance, but on the updated iOS15 failure, so they become setting failure
/ / set the color navigationBar self. NavigationController. NavigationBar. BarTintColor = [UIColor blueColor]; / / set the background color tabBar self. TabBarController. TabBar. BackgroundColor = [UIColor blueColor]; NSMutableDictionary<NSAttributedStringKey, id> *normalAttributes = [NSMutableDictionary dictionary]; [normalAttributes setValue:[UIColor blueColor] forKey:NSForegroundColorAttributeName]; [self.tabBarItem setTitleTextAttributes:normalAttributes.copy forState:UIControlStateNormal]; [self.tabBarItem setTitleTextAttributes:normalAttributes.copy forState:UIControlStateSelected];Copy the code
Solution – Reset the related properties
tabBar
UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init]; / / tabBaritem title selected color appearance. StackedLayoutAppearance. Selected. TitleTextAttributes = @ { NSForegroundColorAttributeName:[UIColor blueColor], }; / / tabBaritem title has not selected the color appearance. StackedLayoutAppearance. Normal. TitleTextAttributes = @ { NSForegroundColorAttributeName:[UIColor blueColor], }; / / tabBar background color appearance. BackgroundColor = [UIColor blackColor]; self.tabBarItem.scrollEdgeAppearance = appearance; self.tabBarItem.standardAppearance = appearance;Copy the code
StandardAppearance -- normal state scrollEdgeAppearance -- the state of a small screen mobile phone in landscape view ScrollEdgeAppearance - The state when scrollView is pulled downCopy the code
navigationBar
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.backgroundColor = [UIColor blackColor];
self.navigationBar.standardAppearance = appearance;
self.navigationBar.scrollEdgeAppearance = appearance;
Copy the code
sectionHeaderTopPadding
Official support
/// Determines if the table view allows its cells to become focused. /// When tableView:canFocusRowAtIndexPath: is implemented, its return value takes precedence over this method. /// Defaults to a system derived value based on platform and other properties of the table view. @property (nonatomic, Getter =isPrefetchingEnabled) BOOL prefetchingEnabled iOS 15 tableView is going to add a height of 22 pixels to the top of each section (above the header), Form a section space between sectionsCopy the code
use
Before in order to coordinate the development of habit, we only need to create an instance of time can be set the spacing of the if (@ the available (iOS 15.0, *)) {tableView. SectionHeaderTopPadding = 0; } if (@available(iOS 15.0, *)) {[UITableView appearance].sectionHeaderToppadding = 0; }Copy the code