我做一個twitter動畫項目作爲練習。我想更改蒙版的背景顏色,但我不知道爲什麼要設置窗口背景顏色來更改它。爲什麼當我在iOS上設置窗口背景色時,蒙版的背景顏色會發生變化?
這是我在的AppDelegate
代碼var mask: CALayer?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.mask = CALayer()
self.mask?.contents = UIImage(named: "twitter")?.cgImage
self.mask?.contentsGravity = kCAGravityResizeAspect
self.mask?.bounds = CGRect(x: 0, y: 0, width: 100, height: 100)
self.mask?.position = self.window!.center
self.window?.rootViewController?.view.layer.mask = self.mask
self.window?.backgroundColor = UIColor(red: 18/255, green: 145/255, blue: 242/255, alpha: 1) // Why?
return true
}
謝謝,我弄清楚了。 – ovo