class OhMyCarSetNavigationBar: UINavigationBar {

    let titleLabel: UILabel = {
        let label = UILabel()
        label.textColor = .black
        label.font = Fonts.mediumTitle2
        return label
    }()

    lazy var previousButton: UIBarButtonItem = {
        let button = UIBarButtonItem(image: UIImage(named: "arrow_left_img"),
                                     style: .plain,
                                     target: self,
                                     action: #selector(previousButtonAction))
        return button
    }()
}

...

UINavigationBar를 상속받아 만든

Untitled

navigationBar 프로퍼티는 읽기 전용이므로, UINavigationController의 네비게이션 바를 직접 설정할 수 없었다.

UINavigationItem을 사용하여 네비게이션 바의 콘텐츠를 설정해야한다. 하지만 이렇게 하면 위와 같이 OhMyCarSetNavigationBar 컴포넌트를 만든 의미가 없어진다.

해결방법

UINavigationBar 가 아닌 UIVIew를 상속받아서 커스텀하기로 결정.