这个图片是UIView类型的。
@property (weak, nonatomic) IBOutlet UIView *iconButton;
CGPoint origin;
CGSize size;
};
CGSize又包括对象的宽度和高度
struct CGSize {
CGFloat width;
CGFloat height;
};
用代码去码一个storyboard
//先实例化一个UIButton类型的btn
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 96, 96)];
//设置普通模式下的btn背景和高亮下的背景。
[btn setBackgroundImage:[UIImage imageNamed: @"biaoqingdi.png" ]forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"chiniupa.png"] forState:UIControlStateHighlighted];
//设置btn的内容
[btn setTitle:@"别点我" forState:UIControlStateNormal];
[btn setTitle:@"点我干嘛" forState:UIControlStateHighlighted];
//设置文字颜色
[btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blueColor] forState: UIControlStateHighlighted];
//文字垂直对齐方式
btn.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
//将按钮添加到视图 这是最重要的一部,可以实例化btn后就写。
[self.view addSubview:btn];