根据此https://stackoverflow.com/a/25408833/2139691,我有以下代码:
let gradient = CAGradientLayer()
gradient.frame = self.view.bounds
gradient.colors = [UIColor.white.cgColor, UIColor.clear.cgColor]
gradient.startPoint = CGPoint(x: 0.5, y: 0.93)
gradient.endPoint = CGPoint(x: 0.5, y: 1)
self.view.layer.mask = gradient
这就是我需要的,请看一下易于阅读的白色文字: