基类二: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<UITabBarDelegate> delegate;    

tabBarItem 

@property(nullable, nonatomic, copy) NSArray<UITabBarItem *> *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<UITabBarItem *> *)items __TVOS_PROHIBITED;   
//在tabBarItem显示之后调用         
- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray<UITabBarItem *> *)items __TVOS_PROHIBITED;    
//在tabBarItem隐藏之前调用    
- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed __TVOS_PROHIBITED; 
//在tabBarItem隐藏之后调用
- (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed __TVOS_PROHIBITED; 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值