CyanHall.com 创建于 2020-12-22, 上次更新:2021-03-30。
👉  github shields 如果有用请点赞。
demo image
    //
//  SDShadowView.swift
//  Created by Cyanhall.com on 21/12/2020.
//
import UIKit

class SDShadowView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setup()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)!
        self.setup()
    }
    func setup() {
        layer.cornerRadius = 5.0;
        layer.masksToBounds = false
        layer.shadowOffset = CGSize.init(width: 0, height: 3)
        layer.shadowColor = UIColor.gray.cgColor
        layer.shadowRadius = 3
        layer.shadowOpacity = 0.4
    }
}
  
参考: UIView with rounded corners and drop shadow?
Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0