zoukankan      html  css  js  c++  java
  • UISB Button

    ViewController.m

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    // 创建普通按钮
    -(void) createUIRectButton
    {
        //创建一个btn对象,根据类型创建btn,
        //圆类型btn: UIButtonTypeRoundedRect
        //通过类方法来创建buttonWithType : 类名+ 方法名
        //不会通过 alloc 创建内存
        UIButton* btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        btn.frame=CGRectMake(100, 100, 100, 40);
        //按钮背景颜色
        btn.backgroundColor=[UIColor greenColor];
        //设置文字显示的颜色
        //P1 颜色
        //P2 状态
    //    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        
        [btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        
        
        
        // 设置按钮上的文字
        //@parameter
        //P1 : 字符串类型 ,显示在按钮上的文字
        //P2 : 设置文字显示状态类型 :UIControlStateNormal ,正常状态
        [btn setTitle:@"按钮01" forState:UIControlStateNormal];
        //P1 显示文字
        //P2 : 设置文字显示状态类型 :UIControlStateHighlighted ,按下状态
        [btn setTitle:@"按钮按下" forState:UIControlStateHighlighted];
        
        //设置按钮风格颜色
        [btn setTintColor:[UIColor yellowColor]];
        
        
        //按钮颜色大小
        btn.titleLabel.font=[UIFont systemFontOfSize:20];
        
        
        [self.view addSubview:btn];
        
    }
    
    
    -(void) createImageBtn
    {
        //创建一个自定义btn
        UIButton *btnImage=[UIButton buttonWithType:UIButtonTypeCustom];
        btnImage.frame=CGRectMake(100, 100, 100, 40);
        btnImage.backgroundColor=[UIColor greenColor];
        UIImage* icon01=[UIImage imageNamed:@"taobao"];
        UIImage* icon02=[UIImage imageNamed:@"tianmao"];
        
        //设置按钮图片方法设置
        //P1 显示的图片对象
        //P2 控件的状态
        
        
        [btnImage setImage:icon01 forState:UIControlStateNormal];
        [btnImage setImage:icon02 forState:UIControlStateHighlighted];
        
        [self.view addSubview:btnImage];
        
        
        
        
        
    }
    
    
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    //    [self createUIRectButton];
        
        [self createImageBtn];
    }
    
    
    @end
  • 相关阅读:
    SpringMVC 使用JSR-303进行校验 @Valid
    Hibernate Tools生成注释
    大型网站架构演变和知识体系(转载)
    eclipse从数据库逆向生成Hibernate实体类
    性能测试公众号,欢迎你的加入~
    mysql使用druid监控配置
    (转)面试为什么需要了解JVM
    (转)什么是缓存击穿?
    Mysql推荐使用规范(转)
    java应用监控工具
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13629518.html
Copyright © 2011-2022 走看看