Angle radius for UIButton not working after upgrading to Xcode 8

advertisements

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?


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