Vinn Vinn - 1 month ago 8
Objective-C Question

ImageView dosen't appear after using clipsToBounds for making it round

The ImageView dosen't appear after using clipsToBounds for making it round, but if i remove these lines it shows on the storyboard.

Here is a snip for the code:

(void)viewDidLoad {[super viewDidLoad];


self.ProfilePhotoImageView.layer.cornerRadius = self.ProfilePhotoImageView.frame.size.width / 2;
self.ProfilePhotoImageView.clipsToBounds = YES;

self.ProfilePhotoImageView.layer.borderWidth = 3.0f;
self.ProfilePhotoImageView.layer.borderColor = [UIColor whiteColor].CGColor;
// Do any additional setup after loading the view.
}

Answer

Place the above code in viewWillAppear method and check.

Like,

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    self.ProfilePhotoImageView.layer.cornerRadius = self.ProfilePhotoImageView.frame.size.width / 2;
    self.ProfilePhotoImageView.clipsToBounds = YES;

    self.ProfilePhotoImageView.layer.borderWidth = 3.0f;
    self.ProfilePhotoImageView.layer.borderColor = [UIColor whiteColor].CGColor;

}