美文网首页SO 问题来了
笔记之“导航”

笔记之“导航”

作者: 失忆的程序员 | 来源:发表于2017-02-16 15:32 被阅读10次

#pragma mark - 即将出现

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

self.navigationController.navigationBar.translucent = YES;

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];

//  就可以实现电池栏白色.

//  想要设置成为黑色把 setStatusBarStyle: 设置成为 UIStatusBarStyleDefault

//self.navigationController.navigationBar.barTintColor = [UIColor clearColor];

// ************ 设置当前导航透明

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"Nav_touming"] forBarMetrics:0];

self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];

}

#pragma mark - 即将消失

- (void)viewWillDisappear:(BOOL)animated {

[super viewWillDisappear:animated];

self.navigationController.navigationBar.translucent = NO; // 导航的透明

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

}

#pragma mark - - 导航

- (void)addNav {

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[UIColor whiteColor]}];

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];

[button setImage:[UIImage imageNamed:@"Nav_fanhui"] forState:(UIControlStateNormal)];

UIBarButtonItem *barbutton = [[UIBarButtonItem alloc] initWithCustomView:button];

self.navigationItem.leftBarButtonItem = barbutton;

[button addTarget:self action:@selector(buttonTouch) forControlEvents:UIControlEventTouchUpInside];

}

- (void)buttonTouch {

XPFLog(@" 放学别走");

[self.navigationController popViewControllerAnimated:YES];

}

#pragma mark - 创建线

- (UIView *)creatgapView:(CGRect)frame{

UIView *view = [[UIView alloc] initWithFrame:frame];

view.backgroundColor = [UIColor colorWithRed:200/255.0 green:200/255.0 blue:200/255.0 alpha:1];

return view;

}

相关文章

网友评论

    本文标题:笔记之“导航”

    本文链接:https://www.haomeiwen.com/subject/xwkhwttx.html