iOS组件之UITabBar详解

引言

UITabBar作为一个标签栏控制,它继承于UIView(有关UIView请参照《iOS组件之UIView详解》,也就是说UITabBar本身是一个视图控件。

目录

1、UITabBar基本属性及方法
2、iOS5.0新增
3、iOS6.0新增
4、iOS7.0新增
5、UITabBarDelegate协议(可选)

1、UITabBar基本属性及方法

// 设置UITabBar的代理

id<UITabBarDelegate> delegate;

// 设置UITabBar的选项值

NSArray  *items;

// 设置UITabBar选中的item

UITabBarItem *selectedItem; 

// 是否动画添加item(冒似没有效果)

- (void)setItems:(NSArray *)items animated:(BOOL)animated;

// 定制化items

- (void)beginCustomizingItems:(NSArray *)items;

// 结束定制化动画

- (BOOL)endCustomizingAnimated:(BOOL)animated;

// 是否定制化

- (BOOL)isCustomizing;

2、iOS5.0新增

// 改变UITabBar的着色(直接通过back背景颜色)

UIColor *tintColor;

// 选中时背景颜色

UIColor *selectedImageTintColor;

// 背景图片

UIImage *backgroundImage;

// 选中的item的背景图片

UIImage *selectionIndicatorImage; 

3、iOS6.0新增

UIImage *shadowImage;

4、iOS7.0新增

UIColor *barTintColor;

UITabBarItemPositioning itemPositioning;

CGFloat itemWidth;


CGFloat itemSpacing;

UIBarStyle barStyle;

BOOL translucent;

5、UITabBarDelegate协议(可选)

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;

- (void)tabBar:(UITabBar *)tabBar willBeginCustomizingItems:(NSArray *)items; 

- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray *)items;
- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray *)items changed:(BOOL)changed;

- (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray *)items changed:(BOOL)changed;  





Comments