渐变色

作者: 本帅不良 | 来源:发表于2020-08-19 18:36 被阅读0次
    import Cocoa
    
    class BackUpFirstSetVC: NSViewController {
    
        @IBOutlet weak var topView: NSBox!
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do view setup here.
            let gradLayer = CAGradientLayer.init()
            gradLayer.startPoint = CGPoint.init(x: 0.5, y: 0.68)
            gradLayer.endPoint = CGPoint.init(x: 0.5, y: 0.11)
            gradLayer.colors = [NSColor.init(hexColorString: "D8D8D8").cgColor,NSColor.init(hexColorString: "EEEEEE").cgColor]
            gradLayer.locations = [0,1]
            topView.wantsLayer = true
            topView.layer = gradLayer
            view.wantsLayer = true
            view.layer?.backgroundColor = NSColor.white.cgColor
            
            
            
        }
        
    }
    
    

    相关文章

      网友评论

          本文标题:渐变色

          本文链接:https://www.haomeiwen.com/subject/yxydjktx.html