Search code examples
iosswiftuiviewautolayout

corner radius on a uiview not working as expected


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-

My code and simulator output is shown in this image. Click Here


Solution

  • My solution in this case is you should put prepareUI method in viewDidLayoutSubviews. Try to add the code below.

    override func viewDidLayoutSubviews() {
        self.prepareUI();
    }