很长一段时间都是用代码来写UITabbarController,试着用xib来写一次,但是遇到tabbar item的图标自定义的时候不知道从何入手,比如定义选定前和选定后的icon图片,这地方还是不太明显。现在用代码记录一下

[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabBar.png"]];

 [[self.RootTabbarController tabBar] setBackgroundImage:[UIImageimageNamed:@"tabbar.png"]]; ITabBarController *tabController = (UITabBarController *)self.window.rootViewController; selectedImage = [UIImage imageNamed:@"contact"];
unselectedImage = [UIImage imageNamed:@"contact"];
UITabBarItem *item3 = [tabBar.items objectAtIndex:2];
[item3 setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
COLOR_APP,UITextAttributeTextColor, nil]
forState:UIControlStateNormal]; // [item3 setFinishedSelectedImage:selectedImage
// withFinishedUnselectedImage:unselectedImage];
[item3 setImage:selectedImage];
[item3 setSelectedImage:selectedImage];

  

这个图片上标记了tabbar item的各种属性

  

UIimageWithRenderingMode:UIImageRenderingModeAlwaysTemplate这个作为ios7里面的新属性,应该注意
很多时候在ios7上使用自定义的tabbar,tabbar顶部会出现一个线,此时解决方案

[[UITabBarappearance] setShadowImage:[[UIImagealloc] init]];
原理是用一个一像素的线图覆盖。

UITabbar item 设置笔记的更多相关文章

  1. Android为ListView的Item设置不同的布局

    MainActivity如下: package cc.testlistview; import java.util.ArrayList; import java.util.HashMap; impor ...

  2. ## GridView 布局:item设置的高度和宽度不起作用、自动适配列数、添加Header和Footer ##

    一.item设置的高度和宽度不起作用 转自:http://www.cnblogs.com/0616--ataozhijia/p/6031875.html [Android Pro] listView和 ...

  3. Sublime Text 3设置笔记

    Sublime Text 3设置笔记 Sublime Text 3设置指南 1. 安装package control 下载package control源码安装包,并解压: http://yun.ba ...

  4. GridView item设置点击背景

    GridView item设置点击背景 android:listSelector="@android:color/transparent"

  5. uitabbar 标题设置 button text attributes only respected for UIControlStateNormal

    uitabbar 标题设置 button text attributes only respected for UIControlStateNormal [[UITabBarItem appearan ...

  6. Typora + picgo + sm.ms 图床设置笔记

    Typora + picgo + sm.ms 图床设置笔记 编辑于2020-03-26 本文部分内容在作者教程的基础上进行了二次编辑,如有重复,纯属必然 在此感谢大佬们的无私付出与分享 之前 用了 g ...

  7. [Android Pro] listView和GridView的item设置的高度和宽度不起作用

    referece to : http://blog.csdn.net/beibeixiao/article/details/9032569 1.     在Android开发中会发现,有时listVi ...

  8. windows设置笔记

    1. 使用Sudo提升权限 http://www.alexblair.org/user-alexblair-post-1046.html 新建 sudo.js 放到 C:\windows\下面,内容如 ...

  9. 系统UITabBar属性设置

    设置背景: [_tabBar setBackgroundImage:[UIImage imageNamed:@"bg_tabbar"]]; 设置某个Item选中的效果: _tabB ...

随机推荐

  1. POJ 3114 Countries in War(强联通分量+Tarjan)

    题目链接 题意 : 给你两个城市让你求最短距离,如果两个城市位于同一强连通分量中那距离为0. 思路 :强连通分量缩点之后,求最短路.以前写过,总感觉记忆不深,这次自己敲完再写了一遍. #include ...

  2. 多线程系列 线程池ThreadPool

    上一篇文章我们总结了多线程最基础的知识点Thread,我们知道了如何开启一个新的异步线程去做一些事情.可是当我们要开启很多线程的时候,如果仍然使用Thread我们需要去管理每一个线程的启动,挂起和终止 ...

  3. linq lambda 分组后排序

    1.lamdba分组排序foodBusinessDistrict.                        GroupBy(x => new                        ...

  4. c# 事件为何要继承EventArgs

    1:继承EventArgs是表示该类可作为事件,删掉了就默认继承object,没人会说你错 ----就是说事件不继承EventArgs 也没有错,也能正常运用,那么继承他的意义是什么呢?看2,3. 觉 ...

  5. photoshop菜单显示不全的解决方法

    photoshop菜单显示不全? 解决方法,选择菜单 编辑->菜单,下拉菜单选择photoshop默认值

  6. IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践

    原文:IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践 最近把编辑器换成IntelliJ IDEA,主要是Ecli ...

  7. SpringMVC 中的Interceptor 拦截器

    1.配置拦截器 在springMVC.xml配置文件增加: <mvc:interceptors>  <!-- 日志拦截器 -->  <mvc:interceptor> ...

  8. Android Calander Event

    必须权限 <uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-pe ...

  9. 数据仓库的自动ETL研究

    但是,在实施数据集成的过程中,由于不同用户提供的数据可能来自不同的途径,其数据内容.数据格式和数据质量千差万别,有时甚至会遇到数据格式不能转换或数据转换格式后丢失信息等棘手问题,严重阻碍了数据在各部门 ...

  10. python2 和python3共存下问题

    一.使用python2 or python3 1. 使用python2 $ python xxx.py 2. 使用python3 $ python3 xxx.py 二.脚本调用 /usr/bin/en ...