title: draw a colored circle in a UITableViewCell
body: <p>I'm trying to generate a UITableViewCell with a colored circle on the left.
  My plan is to use UIButton and manipulate its layer's corner radius.
  However, the colored button never appears.</p>
  
  <p>My xib:</p>
  
  <p><a href="https://i.stack.imgur.com/C48xz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C48xz.png" alt="enter image description here"></a></p>
  
  <p>I have an IBOutlet to my ColorHolder UIButton and a variable for its color.</p>
  
  <pre><code>class ColoredCircleCell: UITableViewCell {
  
      @IBOutlet weak var colorHolder: UIButton!
      @IBOutlet weak var infoRow1: UILabel!
      @IBOutlet weak var infoRow2: UILabel!
  
      var circleColor: CGColor = UIColor.clear.cgColor 
  
      override func awakeFromNib() {
          super.awakeFromNib()
  
          colorHolder.layer.cornerRadius = colorHolder.bounds.size.height / 2
          colorHolder.layer.backgroundColor = circleColor
          colorHolder.clipsToBounds = true
  }
  </code></pre>
  
  <p>In my cellForRowAt indexPath:</p>
  
  <pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "CircleCell", for: indexPath) as! ColoredCircleCell
  
          print(cell.colorHolder.bounds.size.height)
  
          cell.colorHolder.layer.cornerRadius = cell.colorHolder.bounds.size.height / 2
          cell.colorHolder.layer.backgroundColor = UIColor.red.cgColor
  
          cell.infoRow1.text = "H1"
  
          return cell
      }
  </code></pre>
  
  <p>The console tells me  that the size of the cell is 1000. I'm guessing it still has not resized with respect to the row height.</p>
  
  <p><strong>EDIT</strong>: I've narrowed down the problem to <code>cell.colorHolder.layer.cornerRadius = cell.colorHolder.bounds.size.height / 2</code> . The value of <code>cell.colorHolder.bounds.size.height</code> is always 1000. How do I extract the correct value AFTER it has been rendered to the screen? </p>
  
  <p>The output:</p>
  
  <p><a href="https://i.stack.imgur.com/skxoD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/skxoD.png" alt="enter image description here"></a></p>
  
  <p>How do I add a configurable circle for my UITableViewCell?</p>