Frame.size.width Not Returning Correct UIButton Width
<p>I am trying to add a top and right border to my button but not the bottom or left. I looked it up and found a suggestion to do so by adding views to look like borders.</p>

<pre><code>    //Add borders
    let topBorder = UIView(frame: CGRectMake(0, 0, editorBox.frame.size.width/3, 1))
    let rightBorder = UIView(frame: CGRectMake(cancel.frame.size.width, 0, 1, cancel.frame.size.height))
    topBorder.backgroundColor = UIColor(red: 220/255.0, green: 220/255.0, blue: 220/255.0, alpha: 1.0)
    rightBorder.backgroundColor = UIColor(red: 220/255.0, green: 220/255.0, blue: 220/255.0, alpha: 1.0)
    cancel.addSubview(topBorder)
    cancel.addSubview(rightBorder)
</code></pre>

<p>But the resulting Simulator test looks like:</p>

<p><a href="https://i.stack.imgur.com/1NMaX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1NMaX.png" alt="Button border size is not correct"></a></p>

<p><a href="https://i.stack.imgur.com/mDRXr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mDRXr.png" alt="UIButton border size not correct"></a></p>

<p>However, the button is definitely not that big because you can't click on the far right side of it. The auto layout constraints confirm that the button is not that big.</p>

<p><a href="https://i.stack.imgur.com/bPBLh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bPBLh.png" alt="Autolayout constraints"></a></p>

<p>I just want each button to have a border around it's actual 1/3 width size, as set in the constraints. Can anyone tell me what's happening and how to fix it?</p>