Label under image in UIButton

后端 未结 30 2075
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 15:53

I\'m trying to create a button which has some text beneath the icon (sorta like the app buttons) however it seems to be quite difficult to achieve. Any ideas how can I go ab

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 16:43

    Something like this inside UIButton subclass

    public override func layoutSubviews() {
        super.layoutSubviews()
    
        imageEdgeInsets = UIEdgeInsetsMake(-10, 0, 0, 0)
        titleEdgeInsets = UIEdgeInsetsMake(0, -bounds.size.width/2 - 10, -30, 0)
    }
    

提交回复
热议问题