重写UIButton的图片、title Frame
//重写UIButton的图片frame
- (CGRect)imageRectForContentRect:(CGRect)contentRect{
CGRect rect = CGRectMake(63, 0, 10, 30);
return rect;
}
//重写UIButton的title的frame
- (CGRect)titleRectForContentRect:(CGRect)contentRect{
CGRect rect = CGRectMake(-22, 0, CGRectGetWidth(contentRect)+30, 30);
return rect;
}
//重写UIButton的高光方法,空意味什么也没有--目的就是不需要点击按钮时图片高亮
- (void)setHighlighted:(BOOL)highlighted{
}
本文介绍了如何通过重写UIButton的方法来定制按钮的图片显示区域及文字显示区域的位置,并提供了取消按钮高亮效果的具体实现。

2772

被折叠的 条评论
为什么被折叠?



