Set border for UIButton
<p>I am trying to keep border for UIButton.If i use the following code it's working.</p>

<p><strong>Case:1</strong></p>

<pre><code>[[_myButton layer] setBorderWidth:1.0f];
[[_myButton layer] setBorderColor:[UIColor lightGrayColor].CGColor];
</code></pre>

<p>But before when i wrote:</p>

<pre><code>self.baseTypeButton.layer.borderWidth=2.0f;
self.myButton.layer.borderColor=[UIColor lightGrayColor];
</code></pre>

<p>XCode proposed me to do</p>

<p><a href="https://i.stack.imgur.com/bkc9a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bkc9a.png" alt="enter image description here"></a></p>

<p>Now my code changed,but i failed to set border in this case:</p>

<p><strong>Case:2</strong></p>

<pre><code>_myButton.layer.borderWidth=2.0f;
_myButton.layer.borderColor=(__bridge CGColorRef _Nullable)([UIColor lightGrayColor]);
</code></pre>

<p>I am not using <strong>Auto-layout</strong>. Can anybody explain what is the difference between case-1 and case-2. Why case-2 wont work.</p>