定制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. IOS Intro - Write file

    #import <sys/xattr.h> + (NSString *)getFullFilePathInDocuments:(NSString *)subFilePath fileNam ...

  2. C# 反射(Reflection)技术

    本文参考自C#反射(Reflection)详解,纯属学习笔记,加深记忆 在介绍反射前,先介绍一个重要的知识点         .Net应用程序是由程序集(Assembly).模块(Module).类型 ...

  3. selenium+Python(文件下载)

    webdriver允许我们设置默认的文件下载路径,也就是说,文件会自动下载并保存到设置的目录中 下面以Firefox浏览器为例: from selenium import webdriver from ...

  4. c++ 网络编程(七) LINUX下 socket编程 基于套接字的标准I/O函数使用 与 fopen,feof,fgets,fputs函数用法

    原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/9614820.html 一.标准I/O 1,什么是标准I/O?其实是指C语言里的文件操作函数,如 ...

  5. jcef视频教程

    http://www.cnblogs.com/Johness/p/java-cef-1-building.html

  6. extern、 const、static的理解

    1.extern:是一个声明,用来告诉编译器其它文件中存在这个变量,可以拿到使用.是文件级的 2.static:   是一个文件内的声明,只能在本文件内使用,是文件中的(函数级的) 3.const   ...

  7. Config 代码片段

    class Config { private static Config _instance = null; public static Config Instance { get { if (_in ...

  8. [转]VS清除打开项目时的TFS版本控制提示

    本文转自:http://www.cnblogs.com/weixing/p/5219294.html 对于曾经做过TFS版本控制的项目,在版本控制服务不可用的时候,依然会在每次打开项目的时候都提示:当 ...

  9. SailingEase .NET Resources Tool (.NET 多语言资源编辑器)转

    转自:http://www.cnblogs.com/sheng_chao/p/5958846.html 软件下载链接 痛点: 通常我们为了让软件支持多语言,会使用 .NET 自带的资源文件来存储不同的 ...

  10. 转发与重定向的区别(forward与redirect的区别)

    转发:服务器接收到客户端的请求后,在服务器内部传递的过程.最后回复结果给客户端. 重定向:服务器接收到客户端的请求后,回复一个新url给客户端,客户端跳转新url.