定制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. C#编写运行在Linux环境下的采用Mediainfo来获取多媒体文件信息的代码

    项目开始设计的是运行在windows下,所以一开始采用的是windows服务模式来获取多媒体文件信息,后来要求调整为可以在Linux下运行,经过这两天的资料查找,实现了Linux下通过.NET来获取多 ...

  2. Failed to start NodeManager caused by "/var/lib/hadoop-yarn/yarn-nm-recovery/yarn-nm-state/LOCK: Permission denied"

      Hadoop 安装步骤: 0. 安装前准备(节点机器,环境设置,yum源设置) 1. 配置并安装Cloudera-Manager 2. 启动 CM 服务 3. 安装CDH,并配置集群 4. 启动 ...

  3. Python数据分析学习之Numpy

    Numpy的简单操作 import numpy #导入numpy包 file = numpy.genfromtxt("文件路径",delimiter=" ",d ...

  4. Robot Framework的安装、更新与卸载

    Robot Framework的安装.更新与卸载 一,安装RF前的准备 一般就三种执行环境 Python, Jython (JVM) 和 IronPython (.NET): 安装python: #T ...

  5. jQuery validate 设置失去焦点就校验

    <script type="text/javascript"> $(function(){ var flag = $("#addForm").val ...

  6. 【随笔】nginx重启问题和mysql挂了的解决办法

    租了一个阿里云服务器,然后需要一个nginx来处理一下静态文件的访问和动态文件的转发,头一天没有什么问题,第二次打开,各种问题就出来了!解决方法记录一下.... Can't connect to lo ...

  7. Eclipse/MyEclipse 选择Android NDK目录时提示“Not a valid NDK directory”

    Eclipse或者MyEclipse 选择Android NDK目录时提示“Not a valid NDK directory” 在NDK目录中新建一个名称 ndk-build (没有扩展名)的空文件

  8. Environment.Exit(0) 、Application.Exit() 、this.Close() 、this.Dispose()的区别

    Application.Exit:通知winform消息循环退出.程序会等待所有的前台线程终止后才能真正退出.是一种强行退出方式,就像 Win32 的 PostQuitMessage().它意味着放弃 ...

  9. C#操作Redis String字符串

    /// <summary> /// Redis String 操作 /// </summary> public static void Redis_String() { Red ...

  10. 了解:C#三维数组和锯齿数值

    此文章,只需了解,用到的不多. string[,,] three = new string[2, 3, 5];  //定义一个三维数组,给数组分别辅助2,3,5 对此数组的解释://有2个二维数组,每 ...