Alw*_*win 3 uiview ios swift swift3
let shadowPath = UIBezierPath(rect: shadowView.bounds).cgPath
shadowView.layer.shadowColor = UIColor.grey.cgColor
shadowView.layer.shadowOffset = CGSize(width: 0, height: 1)
shadowView.layer.shadowOpacity = 0.5
shadowView.layer.masksToBounds = false
shadowView.layer.shadowPath = shadowPath
shadowView.layer.shadowRadius = 5
Run Code Online (Sandbox Code Playgroud)
我想在我的UIVIew中实现完全相同的阴影.当我使用上面的代码运行我的应用程序时,它分布在4个方面.注意:阴影在两边都很薄,在中心处是粗体.
尝试创建自定义路径:
let shadowPath = UIBezierPath()
shadowPath.move(to: CGPoint(x: someView.bounds.origin.x, y: someView.frame.size.height))
shadowPath.addLine(to: CGPoint(x: someView.bounds.width / 2, y: someView.bounds.height + 7.0))
shadowPath.addLine(to: CGPoint(x: someView.bounds.width, y: someView.bounds.height))
shadowPath.close()
shadowView.layer.shadowColor = UIColor.darkGray.cgColor
shadowView.layer.shadowOpacity = 1
shadowView.layer.masksToBounds = false
shadowView.layer.shadowPath = shadowPath.cgPath
shadowView.layer.shadowRadius = 5
Run Code Online (Sandbox Code Playgroud)
这会给出类似的结果,尝试自定义点位置和其他值以满足您的需求.
| 归档时间: |
|
| 查看次数: |
8951 次 |
| 最近记录: |