iOS/iOS Swift 개발 일기

iOS swift) 런치스크린

Developer-Michelle 2022. 9. 8. 15:54

iOS swift) 런치스크린

 

https://jeong9216.tistory.com/193

 

[iOS/Swift] 런치 스크린 (Launch Screen) / 스플래시 화면

[iOS/Swift] 런치 스크린(Launch Screen) / 스플래시(Splash) 화면 안녕하세요. 개발하는 정주입니다. 오늘은 런치 스크린에 대해 포스팅하려고 합니다. 목차 런치 스크린(Launch Screen)이란? 공식 문서에서

jeong9216.tistory.com

오늘의 의문점: 앱을 만들 때, 런치스크린 3초 띄운 후 탭바컨트롤러가 달린 메인화면을 띄워주려면,

런치스크린 - AppDelegate,

메인 - SceneDelegate에서 각각 조정해주면 되는걸까?

 

<스토리보드 없이 런치스크린 만들기>

1. Info.plist에서 이미지 등록

2. AppDelegate에서 아래와 같이 코드 작성

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    imageArr = ["1.jpeg","2.jpeg","3.jpeg","4.jpeg"]

    let RandomNumber = Int(arc4random_uniform(UInt32(self.imageArr.count)))
    //imageArr is array of images
     let image = UIImage.init(named: "\(imageArr[RandomNumber])")

    let imageView = UIImageView.init(image: image)
    imageView.frame = UIScreen.main.bounds

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()
    window?.rootViewController?.view.addSubview(imageView)
    window?.rootViewController?.view.bringSubview(toFront: imageView)
    window?.makeKeyAndVisible()

    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
        self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
    }
    return true
}

https://stackoverflow.com/questions/32855526/is-there-any-way-to-code-the-launchscreen-programmatically

 

Is there any way to code the LaunchScreen programmatically

I am using Xcode7 and Swift with Storyboards. When I open the LaunchScreen.storyboard, and I try to set a Custom Class on it, Xcode complains that one cannot have a custom class on a LaunchScreen

stackoverflow.com