自定义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);
}
#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);
}
相关文章推荐
- 线程补充
- Android Stuidio打包release版本
- @QueryParam和@PathParam比较
- RequireJS
- work queues
- Android中在xml中使用shape美化UI
- 解决 repo sync error: Exited sync due to fetch errors
- UI控件--SwipeRefreshLayout
- 十五、建造者模式Builder(创建型模式)
- 利用Handler来实现UI线程的更新
- easyUI
- 搜索—Problem_1012-Rescue
- C# FluentNHibernate 连接mysql数据库
- 太原UI设计师讲【设计色彩】一种是自然的色彩一种是显示色彩你知道区别吗?
- Android基础UI之ImageView宽度设定,高度自适应
- Pop Sequence
- 工业控制系统USB存储设备可信管理方案的(ICICS2015)论文PPT:TMSUI: A Trust Management Scheme
- 改变UIPageControl圆点间距
- UINavigationController 之易忘补充
- UITabbar技巧收集