我做一个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