码迷,mamicode.com
首页 > 其他好文 > 详细

UIBarItem 的设置

时间:2015-12-20 17:19:31      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

常见设置如下

#import "TRTabBarController.h"

@interface TRTabBarController ()<TRtabBarDelegate>

@end

@implementation TRTabBarController

   //设置选中后的背景图
    [self.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"delete_btn"]];
   

//遍历tabVarControoler 中的子视图,来改变样式
    for (UIViewController*vc in self.viewControllers) {
    //读取设置过的选中图片
        vc.tabBarItem.selectedImage=[vc.tabBarItem.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        //设置vc的tabbarItem的文字样式
        UITabBarItem*baritem=vc.tabBarItem;
        //设置item的文字位置
        [baritem setTitlePositionAdjustment:UIOffsetMake(0, -2)];
        //字体变大
       NSMutableDictionary *nomalattributes=[NSMutableDictionary dictionary];
        nomalattributes[NSFontAttributeName]=[UIFont systemFontOfSize:13];
        nomalattributes[NSForegroundColorAttributeName]=[UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
        [baritem setTitleTextAttributes:nomalattributes forState:UIControlStateNormal];
        
        
        NSMutableDictionary *selectedAttributes2=[NSMutableDictionary dictionary];
        selectedAttributes2[NSFontAttributeName]=[UIFont systemFontOfSize:13];
       selectedAttributes2[NSForegroundColorAttributeName]=[UIColor colorWithRed:8/255.0 green:232/255.0 blue:13/255.0 alpha:1];
        [baritem setTitleTextAttributes: selectedAttributes2 forState:UIControlStateSelected];

UIBarItem 的设置

标签:

原文地址:http://www.cnblogs.com/zhao-jie-li/p/5061136.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!