美文网首页
UI常用控件

UI常用控件

作者: 空气里的天然呆 | 来源:发表于2016-07-11 23:22 被阅读0次

//    按钮UIButton

//    UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoDark];

UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 80, 80)];

//    frame 表明了控件的坐标和宽高(CGRect 类型)

[button setTitle:@"眼镜哥" forState:UIControlStateNormal];

UIImage *image = [UIImage imageNamed:@"right_normal"];

//    给按钮设置背景图片

[button setBackgroundImage:image forState:UIControlStateNormal];

button.backgroundColor = [UIColor greenColor];

//    按钮监听

[button addTarget:self action:@selector(btnClickLister) forControlEvents:(UIControlEventTouchUpOutside)];

//    添加到视图上面

[self.view addSubview:button];

//    相框UIImageView

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(150, 50, 200, 200)];

UIImage *image1 = [UIImage imageNamed:@"biaoqingdi"];

//    设置imageView显示的图片

imageView.image = image1;

[self.view addSubview:imageView];

//    标签UILabel

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 270, 150, 30)];

//    设置标签的文本

label.text = @"表情弟";

//    设置居中方式

label.textAlignment = NSTextAlignmentCenter;

label.textColor = [UIColor grayColor];

[self.view addSubview:label];

}

}

@end

相关文章

网友评论

      本文标题:UI常用控件

      本文链接:https://www.haomeiwen.com/subject/tfvjjttx.html