UINavigationController

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;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末屯烦,一起剝皮案震驚了整個(gè)濱河市嚷缭,隨后出現(xiàn)的幾起案子糯而,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,657評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件烘豹,死亡現(xiàn)場(chǎng)離奇詭異诺祸,居然都是意外死亡筷笨,警方通過查閱死者的電腦和手機(jī)龟劲,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,889評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門昌跌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來照雁,“玉大人,你說我怎么就攤上這事萍诱∥酆簦” “怎么了?”我有些...
    開封第一講書人閱讀 164,057評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵籍凝,是天一觀的道長静浴。 經(jīng)常有香客問我挤渐,道長,這世上最難降的妖魔是什么浴麻? 我笑而不...
    開封第一講書人閱讀 58,509評(píng)論 1 293
  • 正文 為了忘掉前任软免,我火速辦了婚禮,結(jié)果婚禮上漓骚,老公的妹妹穿的比我還像新娘榛泛。我一直安慰自己曹锨,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,562評(píng)論 6 392
  • 文/花漫 我一把揭開白布齐鲤。 她就那樣靜靜地躺著,像睡著了一般牡肉。 火紅的嫁衣襯著肌膚如雪丑罪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,443評(píng)論 1 302
  • 那天跪另,我揣著相機(jī)與錄音煤搜,去河邊找鬼擦盾。 笑死,一個(gè)胖子當(dāng)著我的面吹牛迹卢,可吹牛的內(nèi)容都是我干的腐碱。 我是一名探鬼主播,決...
    沈念sama閱讀 40,251評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼喂走,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼谋作!你這毒婦竟也來了遵蚜?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,129評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤睡汹,失蹤者是張志新(化名)和其女友劉穎攒钳,沒想到半個(gè)月后雷滋,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體文兢,經(jīng)...
    沈念sama閱讀 45,561評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡姆坚,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,779評(píng)論 3 335
  • 正文 我和宋清朗相戀三年兼呵,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了腊敲。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,902評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡懂昂,死狀恐怖没宾,靈堂內(nèi)的尸體忽然破棺而出循衰,到底是詐尸還是另有隱情,我是刑警寧澤会钝,帶...
    沈念sama閱讀 35,621評(píng)論 5 345
  • 正文 年R本政府宣布顽素,位于F島的核電站,受9級(jí)特大地震影響型型,放射性物質(zhì)發(fā)生泄漏全蝶。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,220評(píng)論 3 328
  • 文/蒙蒙 一绷落、第九天 我趴在偏房一處隱蔽的房頂上張望砌烁。 院中可真熱鬧,春花似錦函喉、人聲如沸管呵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,838評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽坷襟。三九已至,卻和暖如春鸟缕,著一層夾襖步出監(jiān)牢的瞬間排抬,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,971評(píng)論 1 269
  • 我被黑心中介騙來泰國打工番甩, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留届搁,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,025評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像表锻,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子显歧,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,843評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容