欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS 自定義狀態(tài)欄和導(dǎo)航欄詳細(xì)介紹

 更新時間:2016年11月21日 14:58:15   作者:Fiona_L  
這篇文章主要介紹了iOS 自定義狀態(tài)欄和導(dǎo)航欄詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下

iOS 自定義狀態(tài)欄和導(dǎo)航欄

           開發(fā)IOS APP 經(jīng)常會根據(jù)需求更改狀態(tài)欄和導(dǎo)航欄,這里整理了幾種方法,大家可以看下。

導(dǎo)航欄透明

-(void)viewWillAppear:(BOOL)animated { //viewWillAppear中設(shè)置透明
 [super viewWillAppear:animated];
 [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; //用空圖片填充機(jī)位透明
 [self.navigationBar setShadowImage:[UIImage new]];//naviBar底部的seperatorLine
}
-(void)viewDidDisappear:(BOOL)animated { //viewWillAppear中設(shè)置恢復(fù)
 [super viewDidDisappear:animated];
 [self.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
 [self.navigationBar setShadowImage:shadowImage];
}

導(dǎo)航欄漸變

barImageView = self.navigationController.navigationBar.subviews.firstObject;
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
 CGFloat minAlphaOffset = - 64;
 CGFloat maxAlphaOffset = 200; 
 CGFloat offset = scrollView.contentOffset.y; 
 CGFloat alpha = (offset - minAlphaOffset) / (maxAlphaOffset - minAlphaOffset); _barImageView.alpha = alpha;
}

狀態(tài)欄字體顏色改變

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;//黑色
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;//白色

導(dǎo)航欄隱藏

如果導(dǎo)航欄自定義度高,需要完全自己重寫,可以隱藏原來的導(dǎo)航欄,并定義一個新的view

-(void)viewWillAppear:(BOOL)animated {
 [super viewWillAppear:animated];
 self.navigationController.navigationBarHidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated {
 [super viewDidDisappear:animated];
 self.navigationController.navigationBarHidden = NO;
}
-(void)ys_initNavigationBar {
 self.navigationController.interactivePopGestureRecognizer.delegate = (id)self; // 保留右滑pop的手勢
 _naviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 64)];
 _naviBar.backgroundColor = [UIColor whiteColor];
 [self.view addSubview:_naviBar];

UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, _naviBar.height-0.5, self.view.width, 0.5)];
line.backgroundColor = [UIColor colorForHex:@"f0f0f0"];
[_naviBar addSubview:line];

// 返回
backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 20, 44, 44);
[backButton addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backButton];
// 標(biāo)題
naviLable = [[UIButton alloc] initWithFrame:CGRectMake(44, 20, self.view.width-44*2, 44)];
naviLable.backgroundColor = [UIColor clearColor];
naviLable.font = [UIFont systemFontOfSize:16];
naviLabel.textAlignment = NSTextAlignmentCenter;
[self.view addSubview: naviLable];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
 //navigationBar change
 CGFloat minAlphaOffset = 0;
 CGFloat maxAlphaOffset = 40;
 CGFloat offset = scrollView.contentOffset.y;
 CGFloat alpha = (offset - minAlphaOffset) / (maxAlphaOffset - minAlphaOffset);
 _naviBar.alpha = alpha;
 naviLabel.alpha = alpha;
}

相關(guān)文章

  • iOS中nil、Nil、NULL、NSNull詳解

    iOS中nil、Nil、NULL、NSNull詳解

    這篇文章主要介紹了iOS中nil、Nil、NULL、NSNull詳解的相關(guān)資料,需要的朋友可以參考下
    2015-06-06
  • iOS開發(fā)中UISwitch按鈕的使用方法簡介

    iOS開發(fā)中UISwitch按鈕的使用方法簡介

    這篇文章主要介紹了iOS開發(fā)中UISwitch按鈕的使用方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2015-11-11
  • iOS實(shí)現(xiàn)3D卡片式輪播效果

    iOS實(shí)現(xiàn)3D卡片式輪播效果

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)3D卡片式輪播效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • iOS模仿微信長按識別二維碼的多種方式

    iOS模仿微信長按識別二維碼的多種方式

    這篇文章主要介紹了iOS模仿微信長按識別二維碼的兩種方式,文章第二種方式是識別網(wǎng)頁中的二維碼,具體思路詳解大家參考下本文
    2017-07-07
  • iOS 監(jiān)聽回調(diào)機(jī)制KVO實(shí)例

    iOS 監(jiān)聽回調(diào)機(jī)制KVO實(shí)例

    下面小編就為大家分享一篇iOS 監(jiān)聽回調(diào)機(jī)制KVO實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • IOS實(shí)現(xiàn)郵箱模糊匹配的功能

    IOS實(shí)現(xiàn)郵箱模糊匹配的功能

    在一些App的訂單填寫頁,輸入用戶郵箱有個提示郵箱后綴的功能,很好用!還可以根據(jù)各個郵箱類型用戶量來做一個優(yōu)先級的匹配哦。這個功能該如何實(shí)現(xiàn)呢,下面來一起看看。
    2016-08-08
  • 30分鐘快速帶你理解iOS中的謂詞NSPredicate

    30分鐘快速帶你理解iOS中的謂詞NSPredicate

    NSPredicate類是用來定義邏輯條件約束的獲取或內(nèi)存中的過濾搜索。下面這篇文章將通過30分鐘快速帶大家理解iOS中的謂詞NSPredicate類,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03
  • IOS實(shí)現(xiàn)自定義布局瀑布流

    IOS實(shí)現(xiàn)自定義布局瀑布流

    這篇文章主要介紹了IOS實(shí)現(xiàn)自定義布局瀑布流,畫面感非常炫麗,想要學(xué)習(xí)的朋友不要錯過本文
    2016-01-01
  • iOS自定義滑桿效果

    iOS自定義滑桿效果

    這篇文章主要為大家詳細(xì)介紹了iOS自定義滑桿效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • 去除IOS蘋果手機(jī)自帶按鈕樣式的方法(推薦)

    去除IOS蘋果手機(jī)自帶按鈕樣式的方法(推薦)

    下面小編就為大家分享一篇去除IOS蘋果手機(jī)自帶按鈕樣式的方法(推薦),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01

最新評論