最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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]; //用空圖片填充機位透明
 [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)文章

最新評論

大足县| 安多县| 广平县| 启东市| 敦煌市| 天津市| 绍兴市| 东乌珠穆沁旗| 类乌齐县| 苏尼特左旗| 中方县| 拜城县| 西丰县| 故城县| 临潭县| 湘潭市| 苏尼特左旗| 剑阁县| 许昌县| 井冈山市| 凌源市| 扶绥县| 和林格尔县| 横峰县| 宣恩县| 米林县| 当涂县| 望奎县| 宝兴县| 琼中| 荆门市| 克拉玛依市| 扬中市| 香格里拉县| 景德镇市| 西乌| 蒙阴县| 拉萨市| 永靖县| 达州市| 丹寨县|