比如修改UIButton里UIImage的尺寸,需要重寫- (CGRect)imageRectForContentRect:(CGRect)contentRect方法脑豹,其中contentRect就是這個(gè)UIButton的尺寸
如
- (CGRect)imageRectForContentRect:(CGRect)contentRect{
CGFloat imageW = 40; // 這里修改你想改的尺寸
CGFloat imageH = 40;
CGFloat imageX = 40;
CGFloat imageY = 40;
return CGRectMake(imageX, imageY, imageW, imageH);
}
同理捂齐,
-(CGRect)titleRectForContentRect:(CGRect)contentRect就是改變內(nèi)部UILabel的尺寸