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。 –