zoukankan      html  css  js  c++  java
  • iOS开篇——UI之UINavigationController

    把NavigationController设为根视图控制器

        FirstViewController * firstVC = [[FirstViewController alloc]init];
        
        
        UINavigationController * nc = [[UINavigationController alloc]initWithRootViewController:firstVC];
        
        _window.rootViewController = nc;

    NavigationController之间的跳转

    SecondViewController * secondVC = [[SecondViewController alloc]init];
        
        [self.navigationController pushViewController:secondVC animated:YES];
    //压栈方式跳转
      [self.navigationController popViewControllerAnimated:YES];
    //出栈方式返回

    设置toolBar

        [self.navigationController setToolbarHidden:NO animated:YES];
        //toolBar自定制和navigationBar基本相同 可以参考bar的自定制
        //设置是否透明
        self.navigationController.toolbar.translucent = YES;
        //设置样式
        self.navigationController.toolbar.barStyle = UIBarStyleDefault;

    设置NavigationBar

    //加注释 导航条增高20
        self.navigationItem.prompt = @"这是一个注释";
        
        //设置titleView——>
        UIView *view =[[UIView alloc]initWithFrame:CGRectMake(100, 100, 300, 20)];
        view.backgroundColor = [UIColor redColor];
        
        [UIView animateWithDuration:3 delay:2 options:0 animations:^{
            view.backgroundColor = [UIColor yellowColor];
        } completion:nil];
        self.navigationItem.titleView = view;
    
        //设置导航条样式
        self.navigationBar.barStyle = UIBarStyleBlack;
        
        //设置是否透明
         self.navigationBar.translucent = NO;

    创建BarButtonItem  

    UIBarButtonItem * item1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:nil action:nil];
    //系统样式
    
     UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 30)];
        [button setTitle:@"返回" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        UIBarButtonItem * customItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    //自定义
    
    //iOS7以后 用图片设置barButtonItem时 要用imageWithRenderingMode:设置一直显示图片原来色彩
        UIImage * image = [[UIImage imageNamed:@"1-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        UIBarButtonItem * customItem1  = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStyleDone target:nil action:nil];
    //用图片来创建
  • 相关阅读:
    google protobuf
    spawn-fcgi和libfcgi源码解读
    [Linux] 查看进程的上下文切换pidstat
    [MySQL] update语句的redo log过程
    [转载] PHP 8新特性之JIT简介
    [PHP] 新浪企邮webmail在memcache实践使用共享session
    [Go] Golang练习项目-web客服系统即时通讯websocket项目go-fly
    [PHP] php8的jit不支持32位系统WARNING: JIT not supported by host architecture
    [PHP] 源码编译安装opcache
    [PHP] 查找使用的哪个配置文件php.ini
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990199.html
Copyright © 2011-2022 走看看