标签:
改变button内部label和imageView的frame
- (CGRect)titleRectForContentRect:(CGRect)contentRect
- (CGRect)imageRectForContentRect:(CGRect)contentRect
这两个方法在初始化的时候就会调用,此时button自身可能还没有frame,所以可以使用
- (void)setTitle:(NSString *)title forState:(UIControlState)state { [super setTitle:title forState:state]; [self sizeToFit]; } - (void)setImage:(UIImage *)image forState:(UIControlState)state { [super setImage:image forState:state]; [self sizeToFit]; }
在layoutSubviews中设置其内部控件的frame
标签:
原文地址:http://www.cnblogs.com/sea-star3/p/5301033.html