3

I am setting the corner radius of UIButton as follows:

self.btnFBLogin.layer.cornerRadius = self.btnFBLogin.frame.size.height/2;
self.btnFBLogin.layer.masksToBounds = YES;

However, after upgrading to Xcode 8 it is not working. Button is not displayed in screen. However, if I do not set the corner radius it displays as a square box. Has anybody faced similar issue?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Sujit Dalai
  • 43
  • 1
  • 5
  • In XCode 8, due to their new zooming system, bounds and frame are not correct before ViewDidLayoutSubviews (they may exist but with dummy values like 1000 x 1000) - http://stackoverflow.com/a/39495236/3150830 – Ashildr Sep 19 '16 at 10:29

2 Answers2

13

Try This

Make Clip Subviews checked

Hope this helps

Kamlesh Shingarakhiya
  • 2,757
  • 2
  • 16
  • 34
5

In all probability you are running that code too soon (e.g. viewDidLoad). Do it in, say, viewDidLayoutSubviews.

matt
  • 515,959
  • 87
  • 875
  • 1,141