cornerRadius = (view.frame.size.height / 2.0)
Doesn't seem to work as expected. How to solve this? What might be the issue?
Output Screen-
cornerRadius = (view.frame.size.height / 2.0)
Doesn't seem to work as expected. How to solve this? What might be the issue?
Output Screen-
you only need to set clipToBounds true for your View.
Example;
My solution in this case is you should put
prepareUI
method inviewDidLayoutSubviews
. Try to add the code below.I'm guessing that you want your corner radiuses to meet each other, and not have a straight line vertically between them? So that the sides of your red and green buttons meet up in a half circle?
Your view constraints aren't actually resolved until the
viewDidLayoutSubviews()
function, so if your view changes during runtime because of the constraints you have set up, the frame you are calculating your corner radiuses from will change after viewDidLoad. If you useviewDidLayoutSubviews()
instead you should be fine: