IOS-NavigationBar

#import "GCViewConreoller.h"

#import "GCTools.h"

#import "GCViewControllerTow.h"

@implementation GCViewConreoller

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    UIButton *btn = [GCTools ButtonViewWithTitle:@"jump two" andUIButtonType:UIButtonTypeCustom andControlState:UIControlStateNormal andBackgroundColor:[UIColor redColor] anPointofX:10 anPointofY:100 andWidth:100 andHeight:20 andSuperView:nil andTag:1];

    [self.view addSubview:btn];

    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];

    self.view.backgroundColor = [UIColor brownColor];

    

    //设置导航条的样式:

    

    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

    //只有导航条为黑色半透明的情况下才能生效。

    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];

    //导航条默认的高度是44,宽320

    //(UIBarMetrics),设置iphone屏幕模式:横屏,风景模式,竖屏:人像模式。默认是人性模式

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image2.png"] forBarMetrics:UIBarMetricsDefault];

    //导航条不会对背景图片进行压缩,缩小。

    //自动裁剪功能,会把状态栏的图片截掉,

    self.navigationController.navigationBar.clipsToBounds = YES;

    

    //隐藏导航栏:

//    self.navigationController.navigationBarHidden = YES;

    //导航栏被隐藏后,视图控制器的视图会向上伸展。44dpi

    //动画过度隐藏导航条。

//    [self.navigationController setNavigationBarHidden:YES animated:YES];

    

    //注:如果想让导航栏一直隐藏,则需要把导航栏放到视图控制器生命周期活跃的阶段,最好不要放在loadview,或者viewdidload阶段中,因为它们不是每次都会被加载,所以切记!,因为这个是被self调用的,当self转到不活跃状态时,它也不能够再调用函数了。

    //

}

-(void)btnClick{

    GCViewControllerTow *controller = [[GCViewControllerTow alloc] init];

    [self.navigationController pushViewController:controller animated:YES];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值