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

      


      

  • 相关阅读:
    算法--字符串分隔符/字符串匹配算法
    VMware虚拟机磁盘收缩的几种方法
    maven学习--生命周期
    web适配问题
    eclipse按照svn插件
    一台服务器跑两个tomcat
    postgresql数据库
    visio2013破解工具
    多线程学习
    深入理解Java:SimpleDateFormat安全的时间格式化
  • 原文地址:https://www.cnblogs.com/mapanguan/p/5458865.html
Copyright © 2011-2022 走看看