在遮罩的UIView周围添加阴影

时间:2019-09-10 05:47:26

标签: ios swift uiview mask

我正在尝试创建一个带有提示的弹出窗口。以下是此代码

.move-enter {
  opacity: 0.01;
  transform: translate(calc(-50% - 200px), -50%);
}

.move-enter-active {
  opacity: 1;
  transform: translate(-50%, -50%);
  transition: all 500ms ease-in 200ms;
}

.move-exit {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.move-exit-active {
  opacity: 0.01;
  transform: translate(calc(-50% + 200px), -50%);
  transition: all 500ms ease-in 200ms;
}

我用弹出式图像遮盖了UIView。

现在,我想在所有4个面上向UIView添加阴影。我尝试了所有方法。但是阴影不可见

enter image description here

2 个答案:

答案 0 :(得分:2)

将此代码添加到您的视图层:

// set the corner radius
layer.cornerRadius = 6.0
layer.masksToBounds = false
// set the shadow properties
layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize(width: 0, height: 1.0)
layer.shadowOpacity = 0.2
layer.shadowRadius = 4.0

请详细浏览此link

答案 1 :(得分:2)

添加以下代码以将阴影和角半径添加到tipView。清除cancel(isActiveOnly?: boolean): void { this.router.navigate([], { queryParams: { activeOnly: isActiveOnly ? true : false } }); } 并制作backgroundColor的tipView。

clipsToBounds = false