1
似乎无法找到这个答案...黑色阴影添加到UIView的maskView
所以我加一个遮蔽一个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。 –