I'm trying to make my imageView a circle, but it keeps coming out as a diamond. I thought this code would work but it's not:
profilePic.layer.cornerRadius = profilePic.frame.width / 2
profilePic.clipsToBounds = true
Try your code in
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
profilePic.layer.cornerRadius = profilePic.frame.width / 2
profilePic.clipsToBounds = true
}
You might not get perfect circle in every device, try changing 2.0
to different near by values for different size devices.
-(void)viewDidLoad {
self.profilePic.layer.cornerRadius = self.profilePic.frame.size.width / 2.0f;
self.profilePic.clipsToBounds = YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With