iOS Swift 圆角阴影效果参考代码
2020-01-07 本文已影响0人
红色小星
Simulator Screen Shot - iPhone 11 Pro Max - 2020-01-07 at 15.54.28.png
iOS Swift 圆角阴影效果
let yellowView = UIView.init(frame: CGRect(x: 30, y: 100, width: 200, height: 200))
view.addSubview(yellowView)
yellowView.backgroundColor = UIColor.yellow
// 阴影不透明度
yellowView.layer.shadowOpacity = 1.0
// 阴影颜色
yellowView.layer.shadowColor = UIColor.red.cgColor
// 阴影的半径
yellowView.layer.shadowRadius = 20.0
// 阴影偏移量:正数向右 向下,负数向左向上
yellowView.layer.shadowOffset = CGSize(width: 0, height: 0)
// 圆角半径
yellowView.layer.cornerRadius = yellowView.bounds.width / 2