【发布时间】:2021-08-16 06:19:11
【问题描述】:
因为我的构建机器仍在使用 Xcode 12.5,所以即使我使用 @available 来检查,UITabBar 的 scrollEdgeAppearance(Xcode 12.5 的 SDK 中不存在)也会导致构建失败。
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;
}
那么是否可以在代码中进行这种SDK检查,当构建的SDK不是最新的SDK时,这些代码将不会参与构建?像这样
if (BuilDSDK >= someversion)
{
[UITabBar appearance].scrollEdgeAppearance = tabBarAppearance;
}
【问题讨论】:
-
不,不可能
标签: ios xcode xcodebuild