因为我的构建机器仍在使用 Xcode 12.5 ,所以 UITabBar 的scrollEdgeAppearance(在 Xcode 12.5 的 SDK 中不存在)将使构建失败,即使我使用 @available 来检查。
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance* navBarAppearance = [UINavigationBarAppearance new];
navBarAppearance.backgroundColor = [UIColor colorNamed:@"navbar_bg"];
[UINavigationBar appearance].standardAppearance = navBarAppearance;
[UINavigationBar appearance].scrollEdgeAppearance = navBarAppearance;
UITabBarAppearance* tabBarAppearance = [UITabBarAppearance new];
tabBarAppearance.backgroundColor = [UIColor colorNamed:@"second_bg"];
[UITabBar appearance].standardAppearance = tabBarAppearance;
[UITabBar appearance].scrollEdgeAppearance = tabBarAppearance;
[UITableView appearance].sectionHeaderTopPadding = 0;
}
Run Code Online (Sandbox Code Playgroud)
那么是否可以在代码中做这种SDK签入,当构建的SDK不是最新的SDK时,这些代码就不会参与构建呢?像这样
if (BuilDSDK >= someversion)
{
[UITabBar appearance].scrollEdgeAppearance = tabBarAppearance;
}
Run Code Online (Sandbox Code Playgroud)