UI常用控件

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容