How to add rounded corners to a UIView with gradient applied?
问题 I've written custom subclass of UIView that draws a gradient inside of it: import UIKit @IBDesignable class PlayerCellView: UIView { var startColor: UIColor = UIColor(red:0.20, green:0.75, blue:1.00, alpha:1.00) var endColor: UIColor = UIColor(red:0.07, green:0.42, blue:1.00, alpha:1.00) override func draw(_ rect: CGRect) { let context = UIGraphicsGetCurrentContext() let colors = [startColor.cgColor, endColor.cgColor] let locations : [CGFloat] = [0.0, 1.0] let gradient = CGGradient