自定義按鈕
1.自定義按鈕
- 按鈕默認有圖片與LABLE的,自定義按鈕能夠改變它默認的佈局,作成本身想要的樣式
- layoutSubViews重寫其佈局
2.代碼
-(void)layoutSubviews{
self.imageView.frame=CGRectMake(0, 0, 353, 214);
self.titleLabel.frame=CGRectMake(0, 214, 353, 20);
[self.imageView setImage:[UIImage imageNamed:@"2010e3a0c7f88c3f5f5803bf66addd93"]];
//[self setImage:[UIImage imageNamed:@"2c97690e72365e38e3e2a95b934b8dd2"] forState:UIControlStateNormal];
[self setTitle:@"fdsfs" forState:UIControlStateNormal];
[self setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
self.titleLabel.textAlignment=NSTextAlignmentCenter;
//[self setBackgroundColor:[UIColor brownColor]];
}
3.注意按鈕中的lable設置有所不一樣,image同樣
4.github代碼地址