我这里有同样的问题为纽带: 不能添加一个拐角半径和阴影
如果我把maskToBounds = YES,我得到的圆角,但没有阴影如果我把maskToBounds = NO,我得到的影子,但没有圆角。
然后我也跟着在上面的链接的指令,设置maskToBounds = NO“而是设定圆角半径,并设置有圆角的矩形阴影的贝塞尔路径,保持两个相同的半径”。 但后来,我没有得到圆角,我也没有得到任何的影子! (无阴影即正方形图像)能否请你帮我出的呢? 我不知道我做了什么错。 提前致谢。
self.userImageView.backgroundColor = [UIColor redColor];
self.userImageView.clipsToBounds = NO;
self.userImageView.contentMode = UIViewContentModeCenter;
self.userImageView.layer.masksToBounds = NO;
self.userImageView.layer.borderWidth = 1;
self.userImageView.layer.borderColor = [[UIColor grayColor] CGColor];
self.userImageView.layer.shadowOpacity = 1;
self.userImageView.layer.shadowColor = [[UIColor blackColor] CGColor];
self.userImageView.layer.shadowRadius = 8.0f;
self.userImageView.layer.shadowOffset = CGSizeMake(-3, 0);
self.userImageView.layer.shouldRasterize = YES;
self.userImageView.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:[self.userImageView bounds] cornerRadius:10.0f] CGPath];
[self addSubview:self.userImageView];