I\'m aware that the formulae frame.size.width/2
should produce a circle border, however in XCode I am currently experiencing some discrepancies.
I have
Well, Autolayout should be the issue. As it can be seen the height of the imgAvatar
on right is greater than the height of the imgAvatar
on left.
The size of imgAvatar
on right is 190 x 190 and the one on left is 200 x 200, but on the left the corner radius which you are setting is 190/2 i.e. 95px whereas it should be 100px.
Kindly set Height & Width Constraint in your nib file for imgAvatar
, if you do not want the imgAvatar to resize by 1:1.
OR
Try moving your code to viewDidLayoutSubviews
OR
Subclass your UIImageView
and set its corner radius in its awakeFromNib
method
Kindly let us know if it worked. Thanks!