怎样改变 unbutton 的title 和image 的位子

.继承自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);

}


你可能感兴趣的:(怎样改变 unbutton 的title 和image 的位子)