Search code examples
iosswiftxcodeuikitcalayer

How do I round the corners of my app's window in swift?


I'm trying to round the corners of my entire application's window in swift, like the cash app or bonfire. How do I do that?


Solution

  • You can do it in your AppDelegate class

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

    And if you are using SceneDelegate class then

    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.
        }