UINavigationController(导航控制器)

UINavigationController(导航控制器)
界面可以滑动,多用于做轮播图

 //修改导航视图控制器的半透明效果,默认是YES
    self.navigationController.navigationBar.translucent=NO;
    //修改背景颜色
    self.navigationController.navigationBar.barTintColor=[UIColor orangeColor];

     self.title=@"第一页";
  //(1)标题
//    self.navigationItem.title=@"豆瓣电影";
//    self.title=@"天猫首页";
    //两个都可以
    注:self.title后面的标题也会跟着改变

//    UISegmentedControl *seg=[[UISegmentedControl alloc] initWithItems:@[@"信息",@"通话"]];
//    self.navigationItem.titleView=seg;
//    [seg release];

    //可以把label放到titleView上,能修改label的内容,比如字体的大小
//    UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
//    label.text=@"豆瓣电影";
//    self.navigationItem.titleView=label;
//    [label release];
//    label.font=[UIFont systemFontOfSize:25];

创建按钮

 //创建左边的按钮
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(barAction:)];

    //第二种方式
self.navigationItem.rightBarButtonItem=[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"1.jpg"] style:UIBarButtonItemStylePlain target:self action:@selector(barAction:)] autorelease];

    //第三种方式
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"确认" style:UIBarButtonItemStylePlain target:self action:@selector(barAction:)];

    //第四种,使用自定义的视图
    UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal];
    button.frame=CGRectMake(0, 0, 40, 40);
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:button];

跳转页面

//跳转按钮
UIButton *pushButton=[UIButton buttonWithType:UIButtonTypeSystem];
    pushButton.frame=CGRectMake(100, 100, 150, 50);
    pushButton.layer.borderWidth=1;
    pushButton.layer.cornerRadius=10;
    [pushButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    [pushButton setTitle:@"下一页" forState:UIControlStateNormal];
    [self.view addSubview:pushButton];
点击方法
-(void)click:(UIButton *)button{
    //模态跳转(复习)
//    SecondViewController *secVC=[[SecondViewController alloc] init];
//    [secVC setModalTransitionStyle:0];
//    [self presentViewController:secVC animated:YES completion:^{
//        
//    }];

//通过导航视图控制器进行跳转操作
    //1.创建下一页的目标对象
    SecondViewController *secVC=[[SecondViewController alloc] init];
    //2.跳转
    [self.navigationController pushViewController:secVC animated:YES];
    //3.内存管理
    [secVC release];



}

从第二页跳转回来的点击方法

-(void)click:(UIButton *)button{
    ThirdViewController *thirdVC=[[ThirdViewController alloc] init];
    [self.navigationController pushViewController:thirdVC animated:YES];
    [thirdVC release];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值