gpt4 book ai didi

ios - Xcode 4 + 5 兼容代码使用 tabBar setTranslucent

转载 作者:行者123 更新时间:2023-11-28 22:25:34 25 4
gpt4 key购买 nike

我正在尝试在我的 iOS7 应用中使用 [tabBarController.tabBar setTranslucent:NO];。但是,我希望代码使用 xcode 4 进行编译。

所以我在运行时检查iOS版本

float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
if (ver >= 7.0) {

在 Xcode 4 中使用 [tabBarController.tabBar setTranslucent:NO]; 会产生错误..

'UITabBar' 的可见@interface 声明选择器'setTranslucent:'

因为 setTanslucent 在 iOS6 中不可用。

我已经尝试了很多次,但要么代码没有运行,要么导致错误...

  //UITabBar *tabBarr = [tabBarController tabBar];
//if ([tabBarr respondsToSelector:NSSelectorFromString(@"setTranslucent")]) {
// [tabBarr setValue:NO forKey:@"setTranslucent"];
//}

//if ([tabBarr respondsToSelector:@selector(setTranslucent:)]) {
// [tabBarr setTranslucent:NO];
//}

// tabBarController.tabBar.superview.backgroundColor = [UIColor clearColor];

//if ([tabBarr respondsToSelector:@selector(setTranslucent:)]) {
//if ([[tabBarController.tabBar class] instancesRespondToSelector:@selector(setTranslucent:)]) {
//[tabBarController.tabBar setTranslucent:NO];
//[tabBarController.tabBar setBool:NO forKey:@"setTranslucent"];
// [tabBarController.tabBar setValue:NO forKey:@"setTranslucent:"];
//}

我不确定还能尝试什么?

最佳答案

您可以创建一个类别并再次定义属性

@interface UITabBar (OldSDKCompatibility)
@property(nonatomic,getter=isTranslucent) BOOL translucent;
@end

关于ios - Xcode 4 + 5 兼容代码使用 tabBar setTranslucent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19125955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com