美文网首页
UIButton 图片和文字位置偏移

UIButton 图片和文字位置偏移

作者: xu1Peng | 来源:发表于2021-01-13 15:58 被阅读0次
    Simulator Screen Shot - iPhone 11 Pro Max - 2021-01-13 at 15.55.47.png
     switch (style) {
            case MKButtonEdgeInsetsStyleTop:
            {
                imageEdgeInsets = UIEdgeInsetsMake(-labelHeight-space/2.0, 0, 0, -labelWidth);
                labelEdgeInsets = UIEdgeInsetsMake(0, -imageWith, -imageHeight-space/2.0, 0);
            }
                break;
            case MKButtonEdgeInsetsStyleLeft:
            {
                imageEdgeInsets = UIEdgeInsetsMake(0, -space/2.0, 0, space/2.0);
                labelEdgeInsets = UIEdgeInsetsMake(0, space/2.0, 0, -space/2.0);
            }
                break;
            case MKButtonEdgeInsetsStyleBottom:
            {
                imageEdgeInsets = UIEdgeInsetsMake(0, 0, -labelHeight-space/2.0, -labelWidth);
                labelEdgeInsets = UIEdgeInsetsMake(-imageHeight-space/2.0, -imageWith, 0, 0);
            }
                break;
            case MKButtonEdgeInsetsStyleRight:
            {
                imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth+space/2.0, 0, -labelWidth-space/2.0);
                labelEdgeInsets = UIEdgeInsetsMake(0, -imageWith-space/2.0, 0, imageWith+space/2.0);
            }
                break;
            default:
                break;
        }
    

    demo地址:https://github.com/xu1Peng/XPButton.git

    相关文章

      网友评论

          本文标题:UIButton 图片和文字位置偏移

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