【发布时间】:2017-06-22 08:41:26
【问题描述】:
似乎找不到答案...
所以我要像这样向 UIView 添加掩码
//create mask image for uiview
UIImageView *imv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.sentencesContainer.frame.size.width, self.sentencesContainer.frame.size.height)];
imv.image = new;
self.sentencesContainer.maskView = imv;
然后尝试为蒙版添加阴影。
self.sentencesContainer.maskView.layer.masksToBounds = NO;
self.sentencesContainer.maskView.layer.cornerRadius = 10;
self.sentencesContainer.maskView.layer.shadowOffset = CGSizeMake(distanceX, distanceY);
self.sentencesContainer.maskView.layer.shadowRadius = 2;
self.sentencesContainer.maskView.layer.shadowOpacity = opacity;
self.sentencesContainer.maskView.layer.shadowColor = [UIColor blackColor].CGColor;
但是阴影不会变黑。它只是保持与视图相同的颜色。我也尝试将阴影添加到视图层,但这并没有在被遮罩的部分周围产生阴影。有什么建议可以让它变黑吗?
【问题讨论】:
-
你想给 UIView 或 UIImageview 设置阴影?
-
我想给 UIView.maskView 设置阴影。 self.sentencesContainer 是一个 UIView。
标签: ios objective-c uiview shadow