首页 > 其他 > 详细

UIButton 图标与文字上下垂直对齐

时间:2015-11-09 18:38:23      阅读:213      评论:0      收藏:0      [点我收藏+]
    botton.imageEdgeInsets = UIEdgeInsetsMake(- (botton.frame.size.height - botton.imageView.frame.size.height)/2, 0, (botton.frame.size.height - botton.imageView.frame.size.height)/2, 0);
    
    botton.titleEdgeInsets = UIEdgeInsetsMake(0, - (botton.imageView.frame.size.width/2 + botton.titleLabel.frame.size.width/2), 0, (botton.imageView.frame.size.width/2 + botton.titleLabel.frame.size.width/2));

 

核心代码:

UIEdgeInsetsMake(top, left, bottom, right);

由于Y轴通过top、bottom控制,在设置偏移量的时候要同时修改,如只修改一边,则偏移量倍数要x2(X轴同解)

 

UIButton 图标与文字上下垂直对齐

原文:http://www.cnblogs.com/ly1992/p/4950594.html

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