现在的位置: 首页 > 综合 > 正文

『iOS学习笔记』 UIButton-1

2012年12月20日 ⁄ 综合 ⁄ 共 496字 ⁄ 字号 评论关闭

『iOS学习笔记』 UIButton-1

 

UIButton

    /// UIButton
    
    
    //创建UIButton
    UIButton *tmpButton =[[[UIButton alloc] init]autorelease];

    //设置背景颜色
    tmpButton.backgroundColor = [UIColor blueColor];
    
    //设置标题文本
    [tmpButton setTitle:@"MyButton" forState:UIControlStateNormal];
    
    //设置标题文本的颜色
    [tmpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
 
    //设置图片
    UIImage *image3=[UIImage imageNamed:@"a3.png"];      
    [tmpButton setImage:image3 forState:UIControlStateNormal];
    
    //设置位置和大小
    tmpButton.frame = CGRectMake(0, 0, 200, 0);//在这里仅Width有效
     
    //向容器中添加UIButton

抱歉!评论已关闭.