title: Best place to set cornerRadius based on UIButton size in subclass?
body: <p>So I will be having a few different rounded buttons within an app (all the way to circular buttons), and from what I can tell, the easiest way to achieve this is to set the cornerRadius property of the buttons CALayer.</p>
  
  <p>However, I don't want to be doing this manually for every button that requires it in every controller, so I thought a simple subclass that sets this on init would be the way.</p>
  
  <p>I am using Storyboard and Autolayout to position and size the buttons, and assigning them to this subclass.</p>
  
  <pre><code>class RoundedButton: UIButton {
  
      required init(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          self.layer.cornerRadius = self.bounds.size.height / 2.0
          self.clipsToBounds = true
          NSLog("BUTTON BOUNDS: H-%f  W-%f", self.bounds.size.height, self.bounds.size.width)
          NSLog("BUTTON FRAME: H-%f  W-%f", self.frame.height, self.frame.width)
      }
  }
  </code></pre>
  
  <p>But I have come to find out that at this point (i.e. init), the size of neither the frame nor bounds are final. For a button in Storyboard sized (and constrained) to H40 x W40, the bounds/frame sizes are showing H30 x W38.</p>
  
  <p>This means that cornerRadius doesn't get the value I expect.</p>
  
  <p>I have confirmed that at some later point (e.g. when the button can already respond to a tap) that its frame/bounds are indeed H40 x W40.</p>
  
  <p>So after all that, my question is, within the UIButton subclass, when/where can I safely set cornerRadius using the final frame/bounds values of the instance? </p>