UINavigationController
- 導(dǎo)航控制器是一個(gè)堆棧結(jié)構(gòu),只是其中管理的對(duì)象是controller,通過push與pop進(jìn)行controller的切換集漾,我們有兩種方式可以創(chuàng)建導(dǎo)航控制器:
//通過一個(gè)自定義的導(dǎo)航欄和工具欄創(chuàng)建導(dǎo)航控制器
- (instancetype)initWithNavigationBarClass:(nullable Class)navigationBarClass toolbarClass:(nullable Class)toolbarClass;
//使用系統(tǒng)默認(rèn)的導(dǎo)航欄和工具欄,通過一個(gè)根視圖創(chuàng)建導(dǎo)航控制器
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController;
- 通過以下方法對(duì)視圖控制器進(jìn)行管理操作:
//設(shè)置管理的視圖控制器
- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated;
//壓入新的視圖控制器
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
//彈出一個(gè)視圖控制器 返回的是pop的controller
- (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated;
//彈出到某個(gè)視圖控制器 返回所有pop的controller
- (nullable NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
//直接pop到根視圖控制器,返回所有被pop的controller
- (nullable NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated;
//返回棧頂?shù)腸ontroller
@property(nullable, nonatomic,readonly,strong) UIViewController *topViewController;
//返回顯示的controller
@property(nullable, nonatomic,readonly,strong) UIViewController *visibleViewController;
> 上面兩個(gè)方法的區(qū)別在于费封,topViewController是返回被push出的最后一個(gè)controller,但是如果之后又有present進(jìn)行模態(tài)跳轉(zhuǎn)蒋伦,visibleViewController會(huì)返回當(dāng)前顯示的controller弓摘。例如A-push-B-present-C,則topViewController會(huì)返回B痕届,visibleViewController會(huì)返回C韧献。
//返回堆棧中所有的controller
@property(nonatomic,copy) NSArray<__kindof UIViewController *> *viewControllers;
//設(shè)置隱藏導(dǎo)航欄
@property(nonatomic,getter=isNavigationBarHidden) BOOL navigationBarHidden;
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated;
//導(dǎo)航欄對(duì)象,只讀屬性
@property(nonatomic,readonly) UINavigationBar *navigationBar;
//隱藏狀態(tài)欄
@property(nonatomic,getter=isToolbarHidden) BOOL toolbarHidden NS_AVAILABLE_IOS(3_0);
- (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated;
//狀態(tài)欄對(duì)象
@property(null_resettable,nonatomic,readonly) UIToolbar *toolbar;
//導(dǎo)航中的返回手勢(shì)對(duì)象
//iOS7之后研叫,在導(dǎo)航中右劃會(huì)進(jìn)行pop操作锤窑,設(shè)置這個(gè)的enable可以控制設(shè)置手勢(shì)是否失效
@property(nullable, nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer;
//這個(gè)方法是為了iOS方法的命名統(tǒng)一,在導(dǎo)航中蓝撇,其作用和push一樣
- (void)showViewController:(UIViewController *)vc sender:(nullable id)sender;
//屏幕滑動(dòng)的時(shí)候隱藏導(dǎo)航欄果复,常用于tableView,上滑隱藏導(dǎo)航欄,下滑顯示渤昌,帶動(dòng)畫效果
@property (nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe;
//敲擊屏幕可以隱藏與顯示導(dǎo)航欄
@property (nonatomic, readwrite, assign) BOOL hidesBarsOnTap;
//橫屏的時(shí)候隱藏導(dǎo)航欄
@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenVerticallyCompact;
//彈出鍵盤的時(shí)候隱藏導(dǎo)航欄
@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenKeyboardAppears;
//獲取敲擊屏幕的手勢(shì)
@property (nonatomic, readonly, assign) UITapGestureRecognizer *barHideOnTapGestureRecognizer;
//獲取滑動(dòng)隱藏導(dǎo)航欄的手勢(shì)
@property (nonatomic, readonly, strong) UIPanGestureRecognizer *barHideOnSwipeGestureRecognizer;
- Delegate
//視圖將要展示時(shí)調(diào)用的方法
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
//視圖已經(jīng)展示時(shí)調(diào)用的方法
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
//設(shè)置方法設(shè)置導(dǎo)航控制器支持的設(shè)備方向
-(UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);
//這個(gè)方法設(shè)置導(dǎo)航控制器的首選設(shè)備方向
-(UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);
//下面兩個(gè)方法可以對(duì)導(dǎo)航的轉(zhuǎn)場(chǎng)動(dòng)畫進(jìn)行設(shè)置
-(nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController;
-(nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
- 當(dāng)一個(gè)controller被添加到導(dǎo)航中后虽抄,系統(tǒng)會(huì)為它分配一些屬性走搁,如下:
//當(dāng)前controller對(duì)應(yīng)的導(dǎo)航項(xiàng)
@property(nonatomic,readonly,strong) UINavigationItem *navigationItem;
//push的時(shí)候隱藏底部欄,如push后隱藏tabbar
@property(nonatomic) BOOL hidesBottomBarWhenPushed;
//管理它的導(dǎo)航控制器
@property(nullable, nonatomic,readonly,strong) UINavigationController *navigationController;
UINavigtionBar
可以在不使用導(dǎo)航控制器的前提下迈窟,單獨(dú)使用導(dǎo)航欄.
導(dǎo)航欄繼承于UIView私植,所以我們可以像創(chuàng)建普通視圖那樣創(chuàng)建導(dǎo)航欄,比如我們創(chuàng)建一個(gè)高度為80的導(dǎo)航欄车酣,將其放在ViewController的頭部曲稼,代碼如下:
UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 80)];
[self.view addSubview:bar];
也可以設(shè)置導(dǎo)航欄的風(fēng)格屬性,從iOS6之后湖员,UINavigationBar默認(rèn)為半透明的樣式贫悄,從上面也可以看出,白色的導(dǎo)航欄下面透出些許背景的紅色娘摔。導(dǎo)航欄的風(fēng)格屬性可以通過下面的屬性來設(shè)置:
@property(nonatomic,assign) UIBarStyle barStyle;
UIBarStyle是一個(gè)枚舉窄坦,其中大部分的樣式都已棄用,有效果的只有如下兩個(gè):
typedef NS_ENUM(NSInteger, UIBarStyle) {
UIBarStyleDefault = 0,//默認(rèn)
UIBarStyleBlack = 1,//黑色
}
從上面我們可以看到凳寺,iOS6后導(dǎo)航欄默認(rèn)都是半透明的鸭津,我們可以通過下面的bool值來設(shè)置這個(gè)屬性,設(shè)置為NO肠缨,則導(dǎo)航欄不透明逆趋,默認(rèn)為YES:
@property(nonatomic,assign,getter=isTranslucent) BOOL translucent;
下面一些方法用于設(shè)置NavigationBar及上面item的顏色相關(guān)屬性:
tintColor這個(gè)屬性會(huì)影響到導(dǎo)航欄上左側(cè)pop按鈕的圖案顏色和字體顏色,系統(tǒng)默認(rèn)是藍(lán)色
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
BarTintColor用于設(shè)置導(dǎo)航欄的背景色晒奕,這個(gè)屬性被設(shè)置后闻书,半透明的效果將失效:
@property(nullable, nonatomic,strong) UIColor *barTintColor;
兩個(gè)方法用于設(shè)置和獲取導(dǎo)航欄的背景圖案
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (nullable UIImage *)backgroundImageForBarMetrics:(UIBarMetrics)barMetrics;
這里需要注意,默認(rèn)背景圖案是不做縮放處理的吴汪,所以我們使用的圖片尺寸要和導(dǎo)航欄尺寸匹配惠窄,這里面還有一個(gè)UIBarMetrics參數(shù),這個(gè)參數(shù)設(shè)置設(shè)備的狀態(tài)漾橙,如下:
typedef NS_ENUM(NSInteger, UIBarMetrics) {
UIBarMetricsDefault,//正常豎屏狀態(tài)
UIBarMetricsCompact,//橫屏狀態(tài)
};
//設(shè)置導(dǎo)航欄的陰影圖片
@property(nullable, nonatomic,strong) UIImage *shadowImage;
//設(shè)置導(dǎo)航欄的標(biāo)題字體屬性
@property(nullable,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes;
標(biāo)題字體屬性會(huì)影響到導(dǎo)航欄的中間標(biāo)題杆融,如下:
bar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor redColor]};
我們也可以通過下面的屬性設(shè)置導(dǎo)航欄標(biāo)題的豎直位置偏移:
- (void)setTitleVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics;
- (CGFloat)titleVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics;
還有一個(gè)細(xì)節(jié),導(dǎo)航欄左側(cè)pop按鈕的圖案默認(rèn)是一個(gè)箭頭霜运,我們可以使用下面的方法修改:
@property(nullable,nonatomic,strong) UIImage *backIndicatorImage;
@property(nullable,nonatomic,strong) UIImage *backIndicatorTransitionMaskImage;
- 導(dǎo)航欄中item的push與pop操作
UINavigationBar上面不只是簡單的顯示標(biāo)題脾歇,它也將標(biāo)題進(jìn)行了堆棧的管理,每一個(gè)標(biāo)題抽象為的對(duì)象在iOS系統(tǒng)中是UINavigationItem對(duì)象淘捡,我們可以通過push與pop操作管理item組。
//向棧中添加一個(gè)item焦除,上一個(gè)item會(huì)被推向?qū)Ш綑诘淖髠?cè),變?yōu)閜op按鈕乌逐,會(huì)有一個(gè)動(dòng)畫效果
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated;
//pop一個(gè)item
- (nullable UINavigationItem *)popNavigationItemAnimated:(BOOL)animated;
//當(dāng)前push到最上層的item
@property(nullable, nonatomic,readonly,strong) UINavigationItem *topItem;
//僅次于最上層的item竭讳,一般式被推向?qū)Ш綑谧髠?cè)的item
@property(nullable, nonatomic,readonly,strong) UINavigationItem *backItem;
//獲取堆棧中所有item的數(shù)組
@property(nullable,nonatomic,copy) NSArray<UINavigationItem *> *items;
//設(shè)置一組item
- (void)setItems:(nullable NSArray<UINavigationItem *> *)items animated:(BOOL)animated;
- UINavigationBarDelegate
在UINavigationBar中,還有如下一個(gè)屬性:
@property(nullable,nonatomic,weak) id<UINavigationBarDelegate> delegate;
通過代理绢慢,我們可以監(jiān)控導(dǎo)航欄的一些push與pop操作:
//item將要push的時(shí)候調(diào)用洛波,返回NO胰舆,則不能push
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item;
//item已經(jīng)push后調(diào)用
- (void)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item;
//item將要pop時(shí)調(diào)用,返回NO蹬挤,不能pop
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item;
//item已經(jīng)pop后調(diào)用
- (void)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item;
UINavigationItem
Item,從英文上來理解焰扳,它可以解釋為一個(gè)項(xiàng)目,因此,item不是一個(gè)簡單的label標(biāo)題畜份,也不是一個(gè)簡單的button按鈕欣尼,它是導(dǎo)航欄中管理的一個(gè)項(xiàng)目的抽象。說起來有些難于理解愕鼓,通過代碼菇晃,我們就能很好的理解Item的意義。
首先磺送,我們創(chuàng)建一個(gè)item估灿,用UINavigationBar導(dǎo)航欄push出來:
UINavigationItem * item = [[UINavigationItem alloc]initWithTitle:@"title"];
UINavigationBar * bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 64)];
[bar pushNavigationItem:item animated:YES];
除了創(chuàng)建一個(gè)標(biāo)題item,我們也可以創(chuàng)建一個(gè)View類型的item:
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
view.backgroundColor = [UIColor brownColor];
item.titleView = view;
通過下面的屬性域慷,可以給這個(gè)Item添加一個(gè)說明文字,這段文字會(huì)顯示在item的上方:
item.prompt= @"我是navigationItem的說明文字";
上面我們看到的這些抵窒,實(shí)際上只是一個(gè)item的一部分化漆,item還有許多其他的附件,如果我們使導(dǎo)航欄再push出一個(gè)item疙赠,這時(shí)導(dǎo)航欄的左邊會(huì)出現(xiàn)一個(gè)返回按鈕朦拖,這個(gè)返回按鈕實(shí)際上是數(shù)據(jù)第一個(gè)item的,我們做如下的設(shè)置:
UINavigationItem * item = [[UINavigationItem alloc]initWithTitle:@"title"];
UINavigationItem * item2 = [[UINavigationItem alloc]initWithTitle:@"title2"];
item.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"title1" style:nil target:nil action:nil];
[bar pushNavigationItem:item animated:YES];
[bar pushNavigationItem:item2 animated:YES];
上面我們看到的這些捍岳,實(shí)際上只是一個(gè)item的一部分睬隶,item還有許多其他的附件,如果我們使導(dǎo)航欄再push出一個(gè)item银萍,這時(shí)導(dǎo)航欄的左邊會(huì)出現(xiàn)一個(gè)返回按鈕恤左,這個(gè)返回按鈕實(shí)際上是數(shù)據(jù)第一個(gè)item的,我們做如下的設(shè)置:
UINavigationItem * item = [[UINavigationItem alloc]initWithTitle:@"title"];
UINavigationItem * item2 = [[UINavigationItem alloc]initWithTitle:@"title2"];
item.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"title1" style:nil target:nil action:nil];
[bar pushNavigationItem:item animated:YES];
[bar pushNavigationItem:item2 animated:YES];
可以看出戳气,雖然當(dāng)前push出來的item是item2巧鸭,但是左邊的返回按鈕是屬于item的。這里有一點(diǎn)需要注意览闰,雖然backBarButtonItem的標(biāo)題我們可以自定義巷折,但是方法和其他屬性我們都不能定制锻拘,是系統(tǒng)實(shí)現(xiàn)好的击蹲。
當(dāng)然婉宰,我們也可以設(shè)置在push出來新的item的時(shí)候,隱藏前面的返回按鈕类咧,使用如下屬性:
@property(nonatomic,assign) BOOL hidesBackButton;
- (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated;
默認(rèn)為NO蟹腾,設(shè)置為YES將會(huì)隱藏返回按鈕娃殖。
一個(gè)UINavigationItem中,還可以包含許多BarButtonItem炉爆,BarButtonItem是一系列的按鈕芬首,會(huì)出現(xiàn)在導(dǎo)航欄的左側(cè)或者右側(cè)。例如:
UIBarButtonItem * button = [[UIBarButtonItem alloc]initWithTitle:@"按鈕" style:UIBarButtonItemStyleDone target:self action:@selector(click)];
item.leftBarButtonItem = button;
這個(gè)barButtonItem是一個(gè)按鈕螟炫,可以觸發(fā)一個(gè)方法艺晴,這有時(shí)候?qū)ξ覀儊碚f十分有用掸屡。但是有一個(gè)你一定發(fā)現(xiàn)了仅财,如果繼續(xù)push出來Item,原來的返回按鈕不見了盏求,是否隱藏返回按鈕碎罚,由下面這個(gè)屬性控制:
item.leftItemsSupplementBackButton=YES;//YES為顯示
我們也可以通過下面的方法設(shè)置右邊的按鈕,或者直接設(shè)置一組按鈕:
@property(nullable, nonatomic,strong) UIBarButtonItem *leftBarButtonItem;
@property(nullable, nonatomic,strong) UIBarButtonItem *rightBarButtonItem;
- (void)setLeftBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
- (void)setRightBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
@property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *leftBarButtonItems;
@property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *rightBarButtonItems;
- (void)setLeftBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated;
- (void)setRightBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated;
一個(gè)NavigationItem基本上是有三大部分組成的拯勉,當(dāng)前顯示的部分,返回按鈕部分岔帽,和ButtonItem部分导绷,同樣對(duì)于創(chuàng)建和設(shè)置UIBarButoonItem妥曲,也有很多方法供我們使用。
- (instancetype)initWithTitle:(nullable NSString *)title style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
這個(gè)方法通過一個(gè)標(biāo)題創(chuàng)建ButtonItem铸本,其中style參數(shù)可以設(shè)置一個(gè)風(fēng)格遵堵,枚舉如下:
typedef NS_ENUM(NSInteger, UIBarButtonItemStyle) {
UIBarButtonItemStylePlain,
UIBarButtonItemStyleDone,//這兩種風(fēng)格差別并不大,Done風(fēng)格的字體加粗一些
};
我們因?yàn)榭梢酝ㄟ^一個(gè)圖片來創(chuàng)建BarButtonItem:
- (instancetype)initWithImage:(nullable UIImage *)image style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
- (instancetype)initWithImage:(nullable UIImage *)image landscapeImagePhone:(nullable UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
上面這兩個(gè)方法中锡足,第一個(gè)方法與使用文字創(chuàng)建的方法類似壳坪,第二個(gè)方法多了一個(gè)landscapeImagePhone的參數(shù)爽蝴,這個(gè)參數(shù)可以設(shè)置設(shè)備橫屏?xí)r的圖片。
我們也可以使用自定義的View來創(chuàng)建BarButtonItem:
- (instancetype)initWithCustomView:(UIView *)customView;
除了上面一些自定義的創(chuàng)建方法外九孩,對(duì)于BarButtonItem這個(gè)對(duì)象发框,系統(tǒng)也封裝好了許多原生的可以供我們使用,創(chuàng)建的時(shí)候使用如下方法:
UIBarButtonItem * button = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:nil];
上面的SystemItem是系統(tǒng)為我們做好的許多buttonItem的類型宪拥,枚舉如下:
typedef NS_ENUM(NSInteger, UIBarButtonSystemItem) {
UIBarButtonSystemItemDone,//顯示完成
UIBarButtonSystemItemCancel,//顯示取消
UIBarButtonSystemItemEdit, //顯示編輯
UIBarButtonSystemItemSave, //顯示保存
UIBarButtonSystemItemAdd,//顯示加號(hào)
UIBarButtonSystemItemFlexibleSpace,//什么都不顯示她君,占位一個(gè)空間位置
UIBarButtonSystemItemFixedSpace,//和上一個(gè)類似
UIBarButtonSystemItemCompose,//顯示寫入按鈕
UIBarButtonSystemItemReply,//顯示循環(huán)按鈕
UIBarButtonSystemItemAction,//顯示活動(dòng)按鈕
UIBarButtonSystemItemOrganize,//顯示組合按鈕
UIBarButtonSystemItemBookmarks,//顯示圖書按鈕
UIBarButtonSystemItemSearch,//顯示查找按鈕
UIBarButtonSystemItemRefresh,//顯示刷新按鈕
UIBarButtonSystemItemStop,//顯示停止按鈕
UIBarButtonSystemItemCamera,//顯示相機(jī)按鈕
UIBarButtonSystemItemTrash,//顯示移除按鈕
UIBarButtonSystemItemPlay,//顯示播放按鈕
UIBarButtonSystemItemPause,//顯示暫停按鈕
UIBarButtonSystemItemRewind,//顯示退后按鈕
UIBarButtonSystemItemFastForward,//顯示前進(jìn)按鈕
UIBarButtonSystemItemUndo,//顯示消除按鈕
UIBarButtonSystemItemRedo ,//顯示重做按鈕
UIBarButtonSystemItemPageCurl ,//在tool上有效
};
UIToolBar
工具欄和導(dǎo)航欄十分類似葫哗,只是功能更加簡單,工具欄中也有UIBarButtonItem按鈕.
導(dǎo)航欄一般會(huì)出現(xiàn)在視圖的頭部桨螺,與之相對(duì)灭翔,工具欄一般會(huì)出現(xiàn)在視圖的的底部,上面可以填充一些按鈕肝箱,提供給用戶一些操作煌张。創(chuàng)建一個(gè)工具欄如下:
self.view.backgroundColor = [UIColor grayColor];
UIToolbar * tool = [[UIToolbar alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-40, 320, 40)];
[self.view addSubview:tool];
下面是UIToolBar中的一些方法,其中大部分在UINavigationBar中都有涉及链嘀,這里只做簡單的介紹:
//工具欄的風(fēng)格档玻,和導(dǎo)航欄類似,有黑白兩種
@property(nonatomic) UIBarStyle barStyle;
//設(shè)置工具欄上按鈕數(shù)組
@property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *items;
//設(shè)置工具欄是否透明
@property(nonatomic,assign,getter=isTranslucent) BOOL translucent;
//設(shè)置工具欄按鈕
- (void)setItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated;
//設(shè)置item風(fēng)格顏色
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
//設(shè)置工具欄背景色
@property(nullable, nonatomic,strong) UIColor *barTintColor;
//設(shè)置工具欄背景和陰影圖案
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics;
- (nullable UIImage *)backgroundImageForToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics;
- (void)setShadowImage:(nullable UIImage *)shadowImage forToolbarPosition:(UIBarPosition)topOrBottom;
- (nullable UIImage *)shadowImageForToolbarPosition:(UIBarPosition)topOrBottom;