● 属性标签 使得成为全局变量
@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];