ios - 向圆圈添加模糊阴影

标签 ios iphone swift swift3

下午好,

我如何在 swift 3 中实现这样的目标?

circle with blurred drop shadow beneath

阴影中心距圆圈底部约 30px。我尝试过使用阴影技巧,但无法压扁阴影。我也尝试使用 Photoshop 中的图片,但放大后模糊变得很糟糕。

最佳答案

let rect = CGRect(x: 0, y: midView.frame.minY, width: (midView.bounds.width), height: 20.0)

let elipticalPath = UIBezierPath(ovalIn: rect).cgPath
let maskLayer = CAGradientLayer()
maskLayer.frame = midView.bounds
maskLayer.shadowRadius = 15

maskLayer.shadowPath = elipticalPath
maskLayer.shadowOpacity = 0.7
maskLayer.shadowOffset = CGSize.zero
maskLayer.shadowColor = UIColor.gray.cgColor
midView.layer.addSublayer(maskLayer)

关于ios - 向圆圈添加模糊阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45489979/

相关文章:

iphone - NSPredicate 获取 NSSet CoreData 中的特定数据?

uitableview - 点击单元格时如何播放视频?

ios - 如何更改 iOS 中 JTCalenderView 的工作日顺序?

iOS url请求问题

在沙盒模式下重新启动后找不到 iOS 7 应用收据

ios - IPv6 Apple 更新

iphone - 我应该相信 SQLite 事务以避免文件损坏吗?

swift - SQLite Insert 在 swift 中无法正常工作

ios - 在 Facebook 上分享 IOS 11 Swift

ios - Swift 解码字符串 JSON 失败