您的位置:首页 > 产品设计 > UI/UE

自定义UIButton图片和文字的frame

2016-04-22 16:57 381 查看
新建一个Button继承 UIButton

#pragma mark 调整内部UILabel的frame
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
CGFloat imageX = contentRect.size.height * 1/6;
CGFloat imageY = contentRect.size.height * 1/6;
CGFloat imageHeight = (contentRect.size.height) * 2/3;
CGFloat imageWidth = imageHeight;
return CGRectMake(imageX, imageY, imageWidth, imageHeight);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
CGFloat titleX = contentRect.size.width - contentRect.size.height;
CGFloat titleHeight = contentRect.size.height;
CGFloat titleY = 0;
CGFloat titleWidth = contentRect.size.width - contentRect.size.height;
return CGRectMake(titleX, titleY, titleWidth, titleHeight);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: