【发布时间】:2019-05-05 21:42:46
【问题描述】:
我通过情节提要构建了标签栏,为了自定义颜色,我在应用程序委托中更改了它,使用UITabBar.appearance().barTintColor = Color,
我有一个渐变方法是这样的:
func setGradientBackground(colorOne: UIColor, colorTwo: UIColor) {
let gradientlayer = CAGradientLayer()
gradientlayer.frame = bounds
gradientlayer.colors = [colorOne.cgColor, colorTwo.cgColor]
gradientlayer.locations = [0, 1]
gradientlayer.startPoint = CGPoint(x: 1.0, y: 0.0)
gradientlayer.endPoint = CGPoint(x: 0.0, y: 0.0)
layer.insertSublayer(gradientlayer, at: 0)
}
如何将它应用到标签栏的背景?
【问题讨论】: