1.按钮控件使用的类是UIButton  点击按钮会触发某个事件
2.按钮控件的初始化
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom/*自动定制类型*/];
2. frame 设置button的位置信息 如:
button.frame = CGRectMake(100,100,100,100);
3.通过点击button去触发定制的是
[button addTarget:self action:@selector(选择的方法) forControlEvents:UIControlEventTouchUpInside];
4. 向按钮button里设置图片
[button setBackgroundImage:[UIImage imageNamed:@"图片名"] forState:UIControlStateHighlighted];
5.设置button里的字体的颜色
[button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
6.showsTouchWhenHighlighted 点击之后成高亮状态
button.showsTouchWhenHighlighted = YES;
7. selected 判断按钮是否被选中
button.selected = NO;
8.给控件取名字
[button setTitle:@"小海" forState:UIControlStateNormal]; 图片视图
1. 使用的类是UIImageView 用来展示图片的
2.初始化图片
UIImageView *imageView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
3.添加图片
imageView.image = [UIImage imageNamed:@"abc.jpg"];
04-21 19:14
查看更多