gpt4 book ai didi

iphone - 如何在 iOS 5 中移除 UITabbaritem 的渐变/投影

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:51:31 25 4
gpt4 key购买 nike

在 iOS 5 中,有 UI Appearance,是否可以简单地去除渐变?

我这样做是为了自定义我的标签栏,怎样才能去除渐变?

感谢阅读

-(void)UIAppearances
{
//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];


//nav bar
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Rokkitt" size:28.0],
UITextAttributeFont,
nil]];
}
else {
//iOS 4.whatever and below
[self.tabBarController.tabBar insertSubview:imageView atIndex:0];

}

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];

}

最佳答案

UITabBar 可以获取图像并使用其 alpha channel (不透明度)构建选定/未选定图像,或者获取两个处理后的图像按原样使用。

您必须自己将图像提供给 UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage: .除了使用 UITabBar 的 selectedImageTintColor 改变渐变的颜色之外,没有其他方法可以影响它对图像的处理。外观属性。

关于iphone - 如何在 iOS 5 中移除 UITabbaritem 的渐变/投影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8890935/

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