新建一个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了

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2021-09-17
  • 2022-12-23
  • 2021-05-14
  • 2022-02-10
  • 2021-12-08
相关资源
相似解决方案