iOS UI常用控件

● 属性标签 使得成为全局变量

@property(nonatomic,strong) 类型+自定义名称

// 标题标签

@property(nonatomic,strong)UILabel *titleLabel;

// 左边按钮

@property(nonatomic,strong)UIButton *leftBtn;

// 右边标签

@property(nonatomic,strong)UIButton *rightBtn;

// 显示图片

@property(nonatomic,strong)UIImageView *myImageView;

// 通过数组实现对图片的调用

@property(nonatomic,strong)NSArray *imageNames;

● 标签UIlable
// 标签位置设定 frame表明控件的坐标和宽和高

self.titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(origin.x,origin.y,size.width,size.heigh)];

// 标签文本名称

self.titleLabel.text=@"标签名称" ;

// 标签居中

self.titleLabel.textAlignment = NSTextAlignmentCenter;

// 标签展示到测试窗口

[self.view addSubview:self.titleLabel];

● 按钮UIButton

// UIButton buttonWithType表示按键类型及状态

UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];

// 给按钮设置forState按钮状态

[button setBackgroundImage:image forState:UIControlStateNormal];

// 按钮监听

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

// 添加到视图上面

[ self.view addSubview:button];

● 设置相框UIImageView及其大小属性

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(origin.x,origin.y,size.width,size.heigh)];
UIImage *image1 = [UIImage imageNamed:@"图片文件名"];

// 设置imageView显示的图片 即把图片导入到相册中去

imageView.image = image1;
[self.view addSubview:imageView];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值