iOS UIKit框架学习—UITabBar

UITabBar是一个应用之前不同子任务、视图和模式之间选择控制。通常情况下,UITabBar是和UITabBarController配合使用,但是你也可一把他当做单独的控件使用。标签栏总是出现在屏幕的底部边缘和显示一个或多个的内容UITabBarItem的对象。标签栏的外观可以使用背景图片或色调颜色进行自定义,以满足界面的需要。点击项目将选择并突出显示该项目,并使用该项目的选择为应用启用相应的模式。

@class UITabBarItem;
@class UIImageView;
@protocol UITabBarDelegate;

NS_CLASS_AVAILABLE_IOS(2_0) @interface UITabBar : UIView
// 代理
@property(nullable, nonatomic, weak) id delegate;
// 填充的UITabBarItem数组
@property(nullable, nonatomic, copy) NSArray *items;
// 当前选中的item
@property(nullable, nonatomic, weak) UITabBarItem *selectedItem;
// 设置标签栏项目可选动画
- (void)setItems:(nullable NSArray *)items animated:(BOOL)animated;
// 可以自定义标签栏
- (void)beginCustomizingItems:(NSArray *)items __TVOS_PROHIBITED;
// 隐藏自定义的标签栏
- (BOOL)endCustomizingAnimated:(BOOL)animated __TVOS_PROHIBITED;
// 是否可以自定义标签栏
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly, getter=isCustomizing) BOOL customizing __TVOS_PROHIBITED;
#else
- (BOOL)isCustomizing __TVOS_PROHIBITED;
#endif

// 标签栏的底部色值
@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;  // default is nil
// 未被选中标签栏的item被渲染的颜色
@property (nonatomic, readwrite, copy, nullable) UIColor *unselectedItemTintColor NS_AVAILABLE_IOS(10_0) UI_APPEARANCE_SELECTOR;

// 被选中itme的渲染图片颜色
@property(nullable, nonatomic, strong) UIColor *selectedImageTintColor NS_DEPRECATED_IOS(5_0,8_0,"Use tintColor") UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

// 标签栏的背景图片
@property(nullable, nonatomic, strong) UIImage *backgroundImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

// 选择指示器的图片
@property(nullable, nonatomic, strong) UIImage *selectionIndicatorImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

// 边框图片
@property(nullable, nonatomic, strong) UIImage *shadowImage NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;

// 标签栏中标签项目的定位方案
@property(nonatomic) UITabBarItemPositioning itemPositioning NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
// 标签栏项目的宽度
@property(nonatomic) CGFloat itemWidth NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
// 标签项目的空格数量
@property(nonatomic) CGFloat itemSpacing NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;

// 标签栏风格
@property(nonatomic) UIBarStyle barStyle NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

// 是否半透明 默认是YES
@property(nonatomic,getter=isTranslucent) BOOL translucent NS_AVAILABLE_IOS(7_0);
@end

//___________________________________________________________________________________________________

@protocol UITabBarDelegate
@optional
// 当用户选择项目的时候调用
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;
// 自定定义视图显示之前调用
- (void)tabBar:(UITabBar *)tabBar willBeginCustomizingItems:(NSArray *)items __TVOS_PROHIBITED;
// 自定义视图显示后调用
- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray *)items __TVOS_PROHIBITED;
// 自定义将要消失调用
- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray *)items changed:(BOOL)changed __TVOS_PROHIBITED;
// 自定义视图消失后调用
- (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray *)items changed:(BOOL)changed __TVOS_PROHIBITED;

@end

// 标签栏的布局方式
typedef NS_ENUM(NSInteger, UITabBarItemPositioning) {
UITabBarItemPositioningAutomatic, // 自动
UITabBarItemPositioningFill, // 充满
UITabBarItemPositioningCentered, // 居中
} NS_ENUM_AVAILABLE_IOS(7_0);


你可能感兴趣的:(iOS UIKit框架学习—UITabBar)