Vinn
Vinn

Reputation: 21

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. 
}

Upvotes: 0

Views: 54

Answers (2)

Ber.to
Ber.to

Reputation: 1104

If you need the imaged load on viewDidLoad() simple add

 [self layoutIfNeeded];

previous the cornerRadious setup.

Ref: iOS 10 GM with xcode 8 GM causes views to disappear due to roundedCorners & clipsToBounds

Upvotes: 0

Ronak Chaniyara
Ronak Chaniyara

Reputation: 5436

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;

}

Upvotes: 1

Related Questions