在使用clipsToBounds使其成为圆形之后,ImageView不会出现,但是如果我删除它们会在故事板上显示这些线条。
以下是代码片段:
(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.
}
答案 0 :(得分:1)
将上述代码放入viewWillAppear
方法并检查。
像,
-(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;
}
答案 1 :(得分:0)
如果需要viewDidLoad()上的图像加载,请添加
[self layoutIfNeeded];
之前的cornerRadious设置。
参考:iOS 10 GM with xcode 8 GM causes views to disappear due to roundedCorners & clipsToBounds