在iOS应用中绘制静态背景

时间:2014-09-27 03:26:17

标签: ios swift

我的所有我的观点需要静态背景。我是否通过继承UIWindow类在AppDelegate.swift中执行此操作?下面的代码没有用。

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindowGRF?
    ...
}

class UIWindowGRF : UIWindow {
    override init() {
        super.init()
        let gl          = CAGradientLayer()
        let colorTop    = UIColor(red: 59.0/255.0, green: 83.0/255.0, blue: 92.0/255.0, alpha: 1.0).CGColor
        let colorBottom = UIColor(red: 24.0/255.0, green: 40.0/255.0, blue: 45.0/255.0, alpha: 1.0).CGColor
        let colors: Array <AnyObject> = [colorTop, colorBottom]

        gl.colors    = colors
        gl.locations = [0.0, 1.0]
        gl.frame     = self.frame

        self.backgroundColor = UIColor.clearColor()
        self.layer.insertSublayer(gl, atIndex: 0)
    }

    ...
}

0 个答案:

没有答案