zoukankan      html  css  js  c++  java
  • 导航VC的左右item代码

    代码控制左右item:
       UIButton *btnCancel = [UIButton buttonWithType:UIButtonTypeCustom];     btnCancel.frame=CGRectMake(0, 0, 60, 30);     btnCancel.titleLabel.font=[UIFont systemFontOfSize:13];     btnCancel.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;     [btnCancel setTitle:@"返回" forState:UIControlStateNormal];     [btnCancel addTarget:self action:@selector(buttonCancel:) forControlEvents:UIControlEventTouchUpInside];     self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:btnCancel];          UIButton *btnCommit = [UIButton buttonWithType:UIButtonTypeCustom];     btnCommit.frame=CGRectMake(0, 0, 60, 30);     btnCommit.titleLabel.font=[UIFont systemFontOfSize:13];     btnCommit.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;     [btnCommit setTitle:@"提交" forState:UIControlStateNormal];     [btnCancel addTarget:self action:@selector(commitAction:) forControlEvents:UIControlEventTouchUpInside];     self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:btnCommit];


    其他的方法:
    		//第一种:这种设置出来的外观不好控制
        UIImage *searchimage=[UIImage imageNamed:@"search.png"];
    
        UIBarButtonItem *barbtn=[[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStyleDone target:self action:@selector(searchprogram)];    
        barbtn.image=searchimage;
        self.navigationItem.rightBarButtonItem=barbtn;
    
    		//第二种:这种图片将填满button,大小可控
        UIButton*rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,30,30)];
        [rightButton setImage:[UIImage imageNamed:@"back.png"]forState:UIControlStateNormal];
        [rightButton addTarget:self action:@selector(backto)forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem*rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
        self.navigationItem.leftBarButtonItem= rightItem;
    
    
     	 //第三种:
    
    		UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(methodtocall:) ]; 
    
    	如何让navigationItem.rightBarButtonItem隐藏消失?
    	self.navigationItem.rightBarButtonItem=nil;即可实现
    

      


      

  • 相关阅读:
    HTML5表单_form
    HTML第二篇
    快速创建1000个目录
    centos7忘记root密码重置
    centos7更改网卡名称
    centos7磁盘在线扩容
    sqlserver开启远程访问
    安装php后无法动态加载库
    编译openssl和Apache报错checking for SSL_CTX_new... no
    centos6.5设置key登录
  • 原文地址:https://www.cnblogs.com/mapanguan/p/5458865.html
Copyright © 2011-2022 走看看