[iOS] Texture - 1. 개발 환경 설정

박진·2021년 1월 11일
2

iOS

목록 보기
1/2
post-thumbnail

Texture란?

iOS UI 프레임워크로 Storyboard를 사용하지 않고, 코드를 통해 레이아웃을 설계하여 UI 컴포넌트의 모듈화 및 생산성을 높일 수 있습니다. 또한, 레이아웃 설계를 메인 스레드가 아닌 백그라운드 스레드에서 처리하여 퍼포먼스가 우수하며, 메인 스레드의 Overhead를 줄여줍니다.

개발 환경 설정

pod 설치

Profile

pod 'Texture'

프로젝트 생성 후 Profile 파일에 Texture Pod을 추가하고 설치해줍니다.

Pod 설치 방법을 모르겠다면 CocoaPod과 Pod 설치 방법

Storyboard 제거


Main.storyboard 파일을 제거해주세요.


Main을 검색하여 Info.plistStoryboard NameMain storyboard file base name을 제거해주세요.

SceneDelegate 변경

SceneDelegate.swift

...
var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let windowScence = (scene as? UIWindowScene) else { return }
        
        window = UIWindow(windowScene: windowScence)
        window?.windowScene = windowScence
               
        let rootViewController = ViewController()
        window?.rootViewController = rootViewController
        window?.makeKeyAndVisible()
    }
...

SceneDelegate에서 가장 먼저 띄울 ViewController를 지정해줍니다.

ViewController 변경

ViewController.swift

import AsyncDisplayKit

class ViewController: ASDKViewController<ASDisplayNode> {
    
    override init() {
        super.init(node: ASDisplayNode())
        self.node.automaticallyManagesSubnodes = true
        self.node.backgroundColor = .systemBackground
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

AsyncDisplayKit를 import 후 ViewController를 구현해주면,
Texture를 이용한 개발환경 설정이 끝났습니다.

끝내며

평소 코드로 레이아웃을 작성하다보니 iOS에서 스토리보드로 레이아웃을 만드는 점이 불편하였는데, Texture를 이용하여 명시적인 코드로 레이아웃을 만들 수 있다는 점이 크게 장점으로 느껴졌습니다.
다음 글에서는 Texture의 Node에 대하여 알아보겠습니다.

profile
Park Jin

0개의 댓글