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];
        
        */
        

  • 相关阅读:
    GridView里的数据转化为datatable进行数据传输
    asp.net给asp:button同时添加服务器事件和JS事件
    .msi文件安装出现2503、2502错误
    初识IO流——创建目录和文件
    WinRAR注册
    Ubuntu14.04.1 阿里apt源
    Pycharm远程调试
    Couldn't create temporary file to work with
    Ubuntu14中supervisor的安装及配置
    Ubuntu14.04安装pip及配置
  • 原文地址:https://www.cnblogs.com/-ios/p/4672587.html
Copyright © 2011-2022 走看看