zoukankan      html  css  js  c++  java
  • uibutton的常用属性

    //UIButton
        UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
        button.frame=CGRectMake(100, 100, 100, 100);
        button.backgroundColor=[UIColor yellowColor];
        
        //外观控制
        [button setTitle:@"按钮" forState:UIControlStateNormal];
        
        
        //加背景
       // [button setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
        
        //设置文字颜色
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            //第二种改变字体颜色方法
        button.tintColor=[UIColor blackColor];//渲染颜色
        
        //响应事件
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [bgView addSubview:button];
        [bgView release];
        

    //设置
        //文字
        [button setTitle:@"按钮" forState:UIControlStateNormal];
        //文字颜色
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        //背景图片
        [button setBackgroundImage:[UIImage imageNamed:@"1.pug"] forState:UIControlStateNormal];
        //添加事件
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        //添加前景图片(需要镂空png图片)
        [button setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
        
        //获取button上的文字
        NSString *butString = [button titleForState:UIControlStateNormal];
        NSLog(@"文字:%@",butString);
        //获取button上文字的颜色
        UIColor *buttonColor = [button titleColorForState:UIControlStateNormal];
        NSLog(@"%@",buttonColor);
        //获取前景图片
        UIImage *buttonImage = [button imageForState:UIControlStateNormal];
        //获取背景图片
        UIImage *butBgImage = [button backgroundImageForState:UIControlStateNormal];
        
        [self.window addSubview:button];
        [bgview release];
        
        */
        

  • 相关阅读:
    解决ajax无法给js全局变量赋值的问题
    jquery对象和dom对象
    js浏览器调试
    elastic search使用
    elastic search远程测试
    elastic search安装与本地测试
    jQuery常用技巧
    Jquery操作cookie
    HTML特殊字符编码对照表
    DpQuery.js
  • 原文地址:https://www.cnblogs.com/-ios/p/4672587.html
Copyright © 2011-2022 走看看