我正在尝试将 uiimageview 的顶部两个角变圆,但以下代码仅显示普通图像的圆角。我错过了什么吗?谢谢
UIImageView * imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 328)];
imgView.backgroundColor = [UIColor clearColor];
imgView.contentMode = UIViewContentModeScaleAspectFill;
imgView.image = image;
CAShapeLayer * shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 320, 328) byRoundingCorners:2 cornerRadii:CGSizeMake(20.0, 20.0)].CGPath;
shapeLayer.frame = CGRectMake(0, 0, 320, 328);
self.profilePictureView.layer.mask = shapeLayer.mask;
self.profilePictureView.layer.masksToBounds = YES;
[cell.contentView addSubview:self.profilePictureView];
cell.contentView.backgroundColor = [UIColor clearColor];