Can't set CALayer's border color

后端 未结 1 1636
庸人自扰
庸人自扰 2021-01-26 03:53

I\'m trying to customize the appearance of a UIButton, like this:

@IBOutlet weak var button: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()

          


        
相关标签:
1条回答
  • 2021-01-26 04:38

    The problem is that you are running this code too soon (in viewDidLoad). Your cornerRadius calculation depends upon calculateButton.frame, but its value is not known at this time. Move your code into viewDidLayoutSubviews and I think you will find that it works as you expect.

    0 讨论(0)
提交回复
热议问题