如何从左到右设置渐变?
let uiview : UIView = UIView.init(frame: CGRect(x: 50, y: 100, width: 100, height: 10))
let gradient = CAGradientLayer()
gradient.frame = uiview.bounds
gradient.colors = [UIColor.whiteColor().CGColor, UIColor.lightGrayColor().CGColor]
gradient.startPoint = CGPoint(x: 0, y: 0.5)
gradient.endPoint = CGPoint(x: 1, y: 0.5)
uiview.layer.insertSublayer(gradient, atIndex: 0)
self.view.addSubview(uiview)
答案 0 :(得分:0)
查看CAGradientLayer - Core Animation | Apple Developer Documentation
尝试类似:
vagrant up
当然,你可以使用这些值,直到你得到你想要的确切结果。