您的位置:首页 > 产品设计 > UI/UE

UITabBarItem修改背景

2013-06-13 12:00 274 查看
设置UITabBarItem使用自己设计的图片,其中UITabBarItem中有一个方法

[plain]
view plaincopy

- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage   

第一个参数是选中的时候的图片,第二个参数是未选中的时候的图片。

另外,UITabBarItem自带的文字未选中时是白色的,我们想要修改这个字体颜色,怎么办呢?

UITabBarItem的父类UIBarItem提供了这样一个方法

[plain]
view plaincopy

- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;  

说明该方法是支持UIAppearance协议的。这个方法怎么用呢。
下面举个例子

[plain]
view plaincopy

[tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:  
                                          [UIColor whiteColor], UITextAttributeTextColor,  
                                          nil] forState:UIControlStateNormal]; 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS UITabBarItem