自定义UIbutton的样式
2015-11-27 15:27
337 查看
1.继承自UIButton
2.重写这两个方法:
-(CGRect)titleRectForContentRect:(CGRect)contentRect
{
CGFloat titleY = contentRect.size.height *0.6;
CGFloat titleW = contentRect.size.width;
CGFloat titleH = contentRect.size.height - titleY;
return CGRectMake(0, titleY, titleW, titleH);
}
-(CGRect)imageRectForContentRect:(CGRect)contentRect
{
CGFloat imageW = CGRectGetWidth(contentRect);
CGFloat imageH = contentRect.size.height * 0.6;
return CGRectMake(0, 0, imageW, imageH);
}
2.重写这两个方法:
-(CGRect)titleRectForContentRect:(CGRect)contentRect
{
CGFloat titleY = contentRect.size.height *0.6;
CGFloat titleW = contentRect.size.width;
CGFloat titleH = contentRect.size.height - titleY;
return CGRectMake(0, titleY, titleW, titleH);
}
-(CGRect)imageRectForContentRect:(CGRect)contentRect
{
CGFloat imageW = CGRectGetWidth(contentRect);
CGFloat imageH = contentRect.size.height * 0.6;
return CGRectMake(0, 0, imageW, imageH);
}
相关文章推荐
- ui-router
- UItextfield 基本属性 代理方法
- MySQL数据库优化之查询缓存(Query cache)
- CoreBluetooth蓝牙框架BabyBluetooth技术解析
- [Built-in Functions] - S
- UITextView限制输入字数(封装控件)
- Penguins DbTools数据库管理移植差分工具(EXCEL相关) ver 20151124_02
- IQueryable 和 IEnumerable
- AQS源码分析(AbstractQueuedSynchronizer)
- js选择checkbox值,组织成key-value形式,传值到后台
- js选择checkbox值,组织成key-value形式,传值到后台
- [Built-in Functions] - R
- easyui--tab 选项卡组件
- soapUI 环境管理
- 修改UISearchBar背景颜色
- BasicDataSource\DruidDataSource连接池使用
- Java中的享元模式——不可变类的valueOf
- soapUI 读取邮件内容
- ng-value中格式化日期
- 1041. Be Unique (20)