如何快速圆化应用程序窗口的角?

3 xcode calayer uikit ios swift

我正在尝试快速圆化整个应用程序窗口的角,就像现金应用程序或篝火一样。我怎么做?

use*_*632 5

您可以在 AppDelegate 类中执行此操作

func applicationDidBecomeActive(_ application: UIApplication) {
    window?.layer.cornerRadius = 10
    window?.clipsToBounds = true
    window?.backgroundColor = .white
  }
Run Code Online (Sandbox Code Playgroud)

如果您使用的是 SceneDelegate 类,那么

func sceneDidBecomeActive(_ scene: UIScene) {


          window?.layer.cornerRadius = 110
          window?.clipsToBounds = true
          window?.backgroundColor = UIColor.black

        // Called when the scene has moved from an inactive state to an active state.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
    }
Run Code Online (Sandbox Code Playgroud)