iphone开发之设置UITabBar的相关属性

ios默认的样式不太适合我们的应用,可以通过一下方法设置相关属性:




设置背景:
[_tabBar setBackgroundImage:[UIImage imageNamed:@"bg_tabbar"]];




设置某个Item选中的效果:
_tabBar.selectionIndicatorImage = [UIImage imageNamed:@"bar_item_selected"];//设置选中效果图片






设置UITabBarItem文字颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor] }
                                             forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor] }
                                             forState:UIControlStateHighlighted];






设置UITabBarItem未选中与选中时的图片:
[_hotTabItem setFinishedSelectedImage:[UIImage imageNamed:@"1_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"1"]];
    [_searchTabItem setFinishedSelectedImage:[UIImage imageNamed:@"2_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"2"]];
    [_userTabItem setFinishedSelectedImage:[UIImage imageNamed:@"3_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"3"]];




上述方法基本可以满足了。

如果还不行可以自定义实现UITabBar。




你可能感兴趣的:(ios,tabbar)