gpt4 book ai didi

iphone - 如何在选定的 UITabBar 项目之上覆盖?

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

有人知道如何在所选项目之上添加额外的叠加层吗?

后台在app delegate中完成。

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_bgrd.png"]];

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
//iOS 5
[self.tabBarController.tabBar insertSubview:imageView atIndex:1];
}
else {
//iOS 4.whatever and below
[self.tabBarController.tabBar insertSubview:imageView atIndex:0];
}

已选择

enter image description here

未选中

enter image description here

最佳答案

修复了IOS 5,UIappearance函数

 //set the background of tab bar
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_bgrd.png"]];

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
//iOS 5
//[self.tabBarController.tabBar insertSubview:imageView atIndex:1];

[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_bgrd.png"]];
[[UITabBar appearance] setSelectionIndicatorImage:
[UIImage imageNamed:@"navbaractive.png"]];

[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
nil] forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
nil] forState:UIControlStateSelected];

关于iphone - 如何在选定的 UITabBar 项目之上覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8027984/

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