Programmatically adding a shadow to a UIButton label

前端 未结 6 566
盖世英雄少女心
盖世英雄少女心 2021-02-04 03:15

I\'m trying to add a 1px black drop shadow to a button label with no luck. I\'ve tried this:self.setTitleShadowOffset = CGSizeMake(0, -1); but I get:

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 04:12

    for Swift 3:

      button.setTitleShadowColor(UIColor.red, for: .normal)
      button.titleLabel?.shadowOffset = CGSize(width: 2, height: 2)
    

提交回复
热议问题