首页 > 移动平台 > 详细

iOS button文字居中

时间:2016-11-30 14:44:28      阅读:287      评论:0      收藏:0      [点我收藏+]

新建一个UIButton的category

.h

@interface UIButton (QXTitleInCenter)
-(instancetype)init;
@end

.m

@implementation UIButton (QXTitleInCenter)
-(instancetype)init{
    self = [super init]; 
    self.contentEdgeInsets = UIEdgeInsetsMake(-(self.intrinsicContentSize.height) * 0.18(调节文字上下高度的,数值越大文字越靠上方),0, 0, 0); 
    return self;
}
@end

  然后引入这个category,直接用UIButton就OK了

  

iOS button文字居中

原文:http://www.cnblogs.com/ansyxpf/p/6117247.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!