Reputation: 1464
I have a button I'm setting its corner radius like this in ViewDidLoad()
:
self.myBtn.layer.cornerRadius = self.myBtn.frame.size.height / 2
self.myBtn.layer.masksToBounds = true
The result is great on the iPhone X. Screenshot:
But for some reason in devices that has smaller screens (like iPhone SE) the corners are really sharp and the result isn't what I want to achieve. Screenshot:
Does anybody know why is it happening?
Thanks!
Upvotes: 1
Views: 695
Reputation: 1141
Try to call your code in viewDidAppear
(or better in viewDidLayoutSubviews
)
It looks like you're using Autolayout. And it seems your button's layout depends on view's layout.
The problem is: the size of viewController's view may be incorrect when viewDidLoad
called (but it's corrected before viewDidAppear
called).
Upvotes: 2