笔记之“导航”

#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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,547评论 1 14
  • 1.自定义控件 a.继承某个控件 b.重写initWithFrame方法可以设置一些它的属性 c.在layouts...
    圍繞的城阅读 3,479评论 2 4
  • 前言 最近忙完项目比较闲,想写一篇博客来分享一些自学iOS的心得体会,希望对迷茫的你有所帮助。博主非科班出身,一些...
    GitHubPorter阅读 1,453评论 9 5
  • 阔别四年后再来北京进修学习,竟有了一股亲切的味道。承蒙时光不弃,透过指缝的阳光,能寻见过去的模样,又能看到...
    秋婷欣记录阅读 306评论 0 0
  • 终于要出发了,开了近三个小时的车到机场,住维纳酒店,明天八点半的飞机。 刚刚打进来三万,路上还在告诫自己,千万不要...
    行一馆阅读 131评论 0 0