使用swift5.0 仿写TikTok

2022-05-25  本文已影响0人  YannChee

文章和代码还在不断更新中..............

效果图:


2.滑动播放视频 1.骨架搭建-黑白tab切换 2.底部loading.gif

获取资源文件

编码部分:

1.由于我这个项目最低适配iOS13,最新Xcode 新建iOS项目时候会新增SceneDelegate文件. 这是因为iOS13之后,Appdelegate不再负责UI生命周期相关方法,交给SceneDelegate处理.所以window rootViewController设置方法写在Appdelegate里面不起作用了,应该写在SceneDelegate 的func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) 方法里

 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        
        window = UIWindow.init(windowScene: windowScene)
        window?.frame = windowScene.coordinateSpace.bounds
        window?.rootViewController = UINavigationController.init(rootViewController: MainTabBarController.init())
        window?.makeKeyAndVisible() 
    }

2.设置swift 项目的条件编译:

标识可以自定义,例如我的是 MyDebug
在 Build Settings -> Swift Compiler - Custom Flags -> Other Swift Flags -> Debug项 中添加 -D Debug

项目中编写代码使用如下:

#if MyDebug
    print("==========这个是debug模式")
#else
    print("==========这个是release模式")
#endif
上一篇 下一篇

猜你喜欢

热点阅读