美文网首页
iOS- UIButton的上图下文居中对称简单实现

iOS- UIButton的上图下文居中对称简单实现

作者: fly大梦想家 | 来源:发表于2018-08-22 14:00 被阅读21次
            button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            button.titleEdgeInsets = UIEdgeInsetsMake(button.imageView.frame.size.height, -button.imageView.frame.size.width, 0, 0);
            button.imageEdgeInsets = UIEdgeInsetsMake(-button.imageView.frame.size.height, 0, 0, - button.titleLabel.bounds.size.width);
    

    上面两button


    Simulator Screen Shot - iPhone X - 2018-08-22 at 13.59.24.png

    相关文章

      网友评论

          本文标题:iOS- UIButton的上图下文居中对称简单实现

          本文链接:https://www.haomeiwen.com/subject/ottyiftx.html