Is it possible to adjust x,y position for titleLabel of UIButton?

前端 未结 5 678
野趣味
野趣味 2021-01-29 18:25

Is it possible to adjust the x,y position for the titleLabel of a UIButton?

Here is my code:

    UIButton *btn = [UIButton but         


        
5条回答
  •  温柔的废话
    2021-01-29 18:42

    For my projects I've this extension utility:

    extension UIButton {
    
        func moveTitle(horizontal hOffset: CGFloat, vertical vOffset: CGFloat) {
            self.titleEdgeInsets.left += hOffset
            self.titleEdgeInsets.top += vOffset
        }
    
    }
    

提交回复
热议问题