JVS
JVS

Reputation: 2682

Make view circular without masksToBounds

as seen in radar (28342777) - there is an issue in iOS10 when creating UIImageView. Since the views are made automatically to (1000x1000px) sometimes they won't display.

turning off masksToBounds will make them appear correctly, but don't allow to make the circular. I tried using cornerRadius by itself, but it won't work.

Is there a work around?

Upvotes: 2

Views: 191

Answers (1)

Aakash
Aakash

Reputation: 2269

If you need to make your UIImageView circular, you have to do this in viewDidLayoutSubviews instead of viewDidLoad method, as:

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        self.yourImageView.layer.cornerRadius = self.yourImageView.frame.size.height/2
        self.yourImageView.clipsToBounds = true

    }

Upvotes: 1

Related Questions