标签:
自定义GXCustomButton类继承自UIButton类
.m中的代码如下:
#import "GXCustomButton.h"
#define KSImageScale 0.6
@implementation GXCustomButton
#pragma mark 设置Button内部的image的范围
- ( CGRect )imageRectForContentRect:( CGRect )contentRect
{
CGFloat imageW = contentRect. size . width ;
CGFloat imageH = contentRect. size . height * KSImageScale ;
return CGRectMake ( 0 , 0 , imageW, imageH);
}
#pragma mark 设置Button内部的title的范围
- ( CGRect )titleRectForContentRect:( CGRect )contentRect
{
CGFloat titleY = contentRect. size . height * KSImageScale ;
CGFloat titleW = contentRect. size . width ;
CGFloat titleH = contentRect. size . height - titleY;
return CGRectMake ( 0 , titleY, titleW, titleH);
}
@end
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4597795.html