0
如何設置漸變從左到右?添加漸變圖層(swift 2.3)
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)