// 按钮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