定制UITabBar显示样式
来源:互联网 发布:淘宝化妆品品牌 编辑:程序博客网 时间:2024/03/29 21:53
定制UITabBar显示样式
思路是这样子的:
1. 初始化UITabBarController,并装载进来几个其他的ViewController
2. 获取每个控制器的UITabBarItem
3. 单独配置每个ViewController对应的UITabBarItem(其中,文字可以设置偏移量)
就这么简单哦!
问:如何设置UITabBarController高亮选中的颜色值呢?
问:[UITabBar appearance]能干什么?
他是进行UITabBarController全局设定的,也就是说不需要你一个一个的单独设定.
http://www.altinkonline.nl/tutorials/xcode/uitabbar/customizing-background-tintcolor-and-selected-image/
To customize the UITabBar you must have an referrer to the UITabBarController.
Open your class wich refers to the UITabBarController. Add the code below in your class. E.g. in the viewDidLoad: method.
Customize the UITabBar by setting the backgroundimage of your UITabBar.
UIImage *tabBackground = [[UIImage imageNamed:@"tabBarBackground.jpg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; // Set background for all UITabBars [[UITabBar appearance] setBackgroundImage:tabBackground]; // Set background for only this UITabBar [[tabBarController tabBar] setBackgroundImage:tabBackground];
Customize the UITabBar by setting the tintColor for the images.
// Set tint color for the images only for this tabbar [[tabBarController tabBar] setSelectedImageTintColor:[UIColor brownColor]]; [[tabBarController tabBar] setTintColor:[UIColor whiteColor]]; // Set tint color for the images for all tabbars [[UITabBar appearance] setSelectedImageTintColor:[UIColor brownColor]]; [[UITabBar appearance] setTintColor:[UIColor whiteColor]];
Customize the UITabBar by setting the selectionIndicatorImage.
// Set selectionIndicatorImage for this tabbar [[tabBarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"selectedtab.png"]]; // Set selectionIndicatorImage for all tabbars [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selectedtab.png"]];
Now you've an full customized UITabBar!
问:UITabBar的图片尺寸是多少呢?
icon为 60x60pix 的png图片,使用时请用如下格式(如图片名字为 newDay@2x, 使用时直接使用名字即可)
问:如何隐藏UITabBar上的那条黑线?
[[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"tm.png"]];
The shadow image to be used for the tab bar.
The default value is nil, which corresponds to the default shadow image. When non-nil, this property represents a custom shadow image to show instead of the default. For a custom shadow image to be shown, a custom background image must also be set using the backgroundImage property. If the default background image is used, then the default shadow image will be used regardless of the value of this property.
根据这个描述信息来看,如果设定了setShadowImage,那也必须设定背景图片哦.
附录:
1. 样式
2. 一些尺寸
- 定制UITabBar显示样式
- 定制UITabbar样式
- UITabBar 和 UINavigationBar 样式的定制
- 定制 UItabbar
- UITabBar -- 定制
- UITabBar样式
- 关于UITabBarController显示,定义UITabBar的显示样式
- Android控件定制显示样式
- UITABBAR特殊样式设置
- IOS 定制中间突出UItabBar
- IOS 定制中间突出UItabBar
- UITabBar显示隐藏解决方案
- UITabBar-UITabBarItem的选中图片未按照原图样式显示的问题mark
- UI定制第一季第一集:UITabBar
- WSS3SDK之:如何定制快速启动的显示样式
- Apache Direcotry Indexes目录列表显示样式定制
- UITabbar 去除选中后高亮显示
- UITabBar的隐藏与显示
- DNA Sorting
- zoj 3789 并查集 删除操作
- 程序员永远的痛之字符编码的奥秘
- liferay favicon的修改
- Getting Started with USB Driver Development
- 定制UITabBar显示样式
- OCP 1Z0 051 QUESTION NO: 60
- 只有iPhone5支持lowLightBoost,但iPhone5S不支持
- [leetcode]Reorder List
- Airplay 教程: 一个 Apple TV 多人竞答游戏(4)
- Eclipse上GIT插件EGIT使用手册
- GPS-Graph Processing System Graph Coloring算法分析 (三)
- 一致性Hash简介和使用
- OpenStack Keystone的基本概念理解