定制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显示样式的更多相关文章

  1. SharePoint 2013 定制搜索显示模板(二)

    前言 之前一篇博客,简单的介绍了如何定制搜索显示模板,这一次,我们介绍一下如何定制搜索显示时,弹出来的那个页面,相信这个大家也都会遇到的. 1.第一部分就是搜索显示模板的部分,第二部分就是搜索项目详情 ...

  2. 第二篇、Swift_自定义 tabbar 的 badgeValue显示样式

    在实际的开发中,我们常常需要根据实际的需求,去改变bageValue的显示样式,默认是红色的背景,白色的字体颜色 使用方式: class BKTabBarController: UITabBarCon ...

  3. SharePoint 2013 定制搜索显示模板

    前言 之前我们已经介绍了一些关于搜索的相关配置,当然,用户关于搜索的要求可能是各种各样.有时候,用户会说,你们的显示结果太Low了,确实是:不过,在SharePoint中,我们可以很容易的定制搜索结果 ...

  4. Siteserver-stl:searchOutput(搜索结果)自定义显示样式

    stl:searchOutput 自定义显示样式 自定义搜索提交表单需要在<stl:searchOutput>中嵌入显示搜索结果的标签,必须包含的标签 有<stl:pageConte ...

  5. Win32编程:窗口类样式+窗口外观样式+窗口显示样式

    1.窗口类样式WNDCLASS.style CS_VREDRAW 提供窗口位置变化事件和高度变化事件的处理程序,功能是重绘窗口 CS_HREDRAW 提供窗口位置变化事件和宽度变化事件的处理程序,功能 ...

  6. POWERDESIGNER中显示样式设置

    1.调整表.视图的显示样式. 右键选中的对象,选择format(或ctrl+t),在弹出窗口中选中content,可以设置只显示表名还是把所有列也显示出来. 2.如何显示表中字段的code. tool ...

  7. 改变HTML中超链接的显示样式

    更详细的内容请参考:http://www.w3school.com.cn/tags/tag_a.asp HTML中的代码如下: <a class="news_title" t ...

  8. 解决eclipse maven工程中src/main/resources目录下创建的文件夹所显示样式不是文件夹,而是"包"图标样式的问题

    参考:http://blog.csdn.net/luwei42768/article/details/72268246 eclipse项目中创建maven项目后,有时在执行命令maven update ...

  9. Sharepoint 2013内容查询Web部件自定义显示样式(实战)

    分享人:广州华软 星尘 一. 前言 在进行Sharepoint开发时,经常会遇到内容展示个性化需求的问题,当然如果通过自定义开发控件对于内容展示的需求基本都可以很好的解决,但自定义开发也有不好的地方, ...

随机推荐

  1. python调用另一个.py文件中的类和函数

    同一文件夹下的调用 1.调用函数 A.py文件如下:def add(x,y):    print('和为:%d'%(x+y)) 在B.py文件中调用A.py的add函数如下: import AA.ad ...

  2. SpagoBI系列----------[01]SpagoBI简介及安装步骤

    商务智能套件SpagoBI提供一个基于J2EE的框架用于管理BI对象如报表.OLAP分析.仪表盘.记分卡以及数据挖掘模型等的开源BI产品.它提供的BI管理器能 够控制.校验.验证与分发这些BI对象. ...

  3. unittest 几个重要概念

    unittest是一个python版本的junit,junit是java中的单元测试框架,unittest实现了很多junit中的概念,比如我们非常熟悉的test case, test suite等, ...

  4. selenium+Python(文件上传)

    文件上传操作也比较常见功能之一,上传功能没有用到新有方法或函数,上传过程一般要打开一个本地窗口,从窗口选择本地文件添加.所以,一般会卡在如何操作本地窗口添加上传文件只要定位上传按钮,通send_key ...

  5. Struts中Validate()和validateXxx的使用

    Struts中Validate()和validateXxx的使用 学习struts2之后,你会发现validate在之前是没有的!它是怎么实现的呢? validate和validateXxxx都是拦截 ...

  6. 【ExtJS】简单布局应用

    前几天学习了ExtJS的各种布局后,以下就是各种实践,从简单做起. 实现目的: 一个提交表单页,一个显示信息页,表单为个人基本资料输入,显示页为基本信息展示. 内容: 总体布局为border布局,展示 ...

  7. 1.8 js基础(常用方法小结)

    1.获取随机数 var rdm=function(n,m){ return parseInt(n+Math.random()*(m-n)); } 2.位数不够补0 function toDou(inu ...

  8. Selenium库简介

    Selenium是一个自动化测试工具,利用它可以驱动浏览器执行特定的动作,如点击.下拉等操作,同时还可以获取浏览器当前呈现的页面的源代码,做到可见即可爬.对于一些JavaScript动态渲染的页面来说 ...

  9. [Visual studio code 常见问题解决] ——中文乱码、

    中文乱码问题解决 描述:刚开始安装VScode要打开含中文的文件,都会出现乱码,这时只要点击右下方的“UTF-8”改成“GB2312”即可.但每次都改是很麻烦的,所以要使得VScode默认支持GB23 ...

  10. Codeforces 809D. Hitchhiking in the Baltic States

    Description 给出 \(n\) 个数 \(a_i\),每一个数有一个取值 \([l_i,r_i]\) ,你来确定每一个数,使得 \(LIS\) 最大 题面 Solution 按照平时做法,设 ...