基类二:UITabBar

一、简述

UITabBar对象控制在不同的任务、视图或模式之间切换。

包含于UITabBarController中,是一个可以管理一系列自定义视图显示的程序对象。

继承关系:UITabBar--->UIView-->UIResponder-->NSObject

二、属性

UITabBarItem的位置

typedef NS_ENUM(NSInteger, UITabBarItemPositioning) {
    UITabBarItemPositioningAutomatic,
    UITabBarItemPositioningFill,
    UITabBarItemPositioningCentered,
} NS_ENUM_AVAILABLE_IOS(7_0);

tabBar代理

@property(nullable, nonatomic, weak) id delegate;    

tabBarItem 

@property(nullable, nonatomic, copy) NSArray *items; 

选中的tabBarItem

@property(nullable, nonatomic, weak) UITabBarItem *selectedItem;

iOS7.0以上的tabBar的tintColor已更改,它不再影响tabBar的背景,若要为tabBar的背景着色,请使用barTabBar

@property(null_resettable, nonatomic, strong) UIColor *tintColor NS_AVAILABLE_IOS(5_0);
@property(nullable, nonatomic, strong) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; 

未选中的tabBarItemColor

@property (nonatomic, readwrite, copy, nullable) UIColor *unselectedItemTintColor NS_AVAILABLE_IOS(10_0) UI_APPEARANCE_SELECTOR;

选中的tabBarItemColor

@property(nullable, nonatomic, strong) UIColor *selectedImageTintColor NS_DEPRECATED_IOS(5_0,8_0,"Use tintColor") UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

tabBar背景图片,会充满整个tabBar

@property(nullable, nonatomic, strong) UIImage *backgroundImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

图像在tabBar的顶部,tabBarItem的后边

@property(nullable, nonatomic, strong) UIImage *selectionIndicatorImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

默认值为零。非零时,显示自定义阴影图像而不是默认阴影图像。

要显示自定义阴影,自定义背景图像还必须设置-backundgroundimage:

如果使用默认背景图像,则将使用默认阴影图像。

@property(nullable, nonatomic, strong) UIImage *shadowImage NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;

tabBarItem填充位置,默认水平填充,呼应第一个枚举。

@property(nonatomic) UITabBarItemPositioning itemPositioning NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

>0  自定义tabBarItem的宽度,<=0 系统自定义的宽度

@property(nonatomic) CGFloat itemWidth NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;

>0  自定义tabBarItem之间的间距   <= 系统自定义

@property(nonatomic) CGFloat itemSpacing NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;

tabBar样式,默认黑色

@property(nonatomic) UIBarStyle barStyle NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

tabBar透明度,默认yes

@property(nonatomic,getter=isTranslucent) BOOL translucent NS_AVAILABLE_IOS(7_0);

 

三、delegate方法

//在tabBarItems显示之前调用
- (void)tabBar:(UITabBar *)tabBar willBeginCustomizingItems:(NSArray *)items __TVOS_PROHIBITED;   
//在tabBarItem显示之后调用         
- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray *)items __TVOS_PROHIBITED;    
//在tabBarItem隐藏之前调用    
- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray *)items changed:(BOOL)changed __TVOS_PROHIBITED; 
//在tabBarItem隐藏之后调用
- (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray *)items changed:(BOOL)changed __TVOS_PROHIBITED; 

 

 

你可能感兴趣的:(iOS基类)