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;即可实现
    

      


      

  • 相关阅读:
    基于Haproxy+Keepalived构建高可用负载均衡集群
    基于 Haproxy 构建负载均衡集群
    shell for循环练习题99乘法表
    帮软件同事写的vsftpd服务虚拟用户管理脚本
    sed文件处理练习题
    判断ssh登录密码验证错误超过5次的IP被拉黑
    使用shell中数组功能生成自己的手机号
    利用Crontab设置每个月第一个周六的17:30执行/opt/shell.sh 脚本
    Tomcat 项目代码上线步骤详解
    Jar/War/Ear等包的作用与区别详解
  • 原文地址:https://www.cnblogs.com/mapanguan/p/5458865.html
Copyright © 2011-2022 走看看