기본적으로 이렇게 구현하지만

final class MainTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupTabBar()
        setupViewControllers()
    }
    
    private func setupTabBar() {
        tabBar.tintColor = .systemBlue
        tabBar.unselectedItemTintColor = .gray
        tabBar.backgroundColor = .white
    }
    
    private func setupViewControllers() {
        let homeVC = ViewController()
        homeVC.tabBarItem = UITabBarItem(
            title: "홈",
            image: UIImage(systemName: "house"),
            selectedImage: UIImage(systemName: "house.fill")
        )
        
        let clubVC = ViewController()
        clubVC.tabBarItem = UITabBarItem(
            title: "내 클럽",
            image: UIImage(systemName: "ellipsis.message"),
            selectedImage: UIImage(systemName: "ellipsis.message.fill")
        )
        
        let notificationVC = ViewController()
        notificationVC.tabBarItem = UITabBarItem(
            title: "알림",
            image: UIImage(systemName: "bell"),
            selectedImage: UIImage(systemName: "bell.fill")
        )
        
        let profileVC = ViewController()
        profileVC.tabBarItem = UITabBarItem(
            title: "프로필",
            image: UIImage(systemName: "person"),
            selectedImage: UIImage(systemName: "person.fill")
        )
        
        // 뷰컨트롤러 배열 설정
        self.viewControllers = [
            UINavigationController(rootViewController: homeVC),
            UINavigationController(rootViewController: clubVC),
            UINavigationController(rootViewController: notificationVC),
            UINavigationController(rootViewController: profileVC)
        ]
    }
}

우리는 디자이너 선생님들이 주신대로 구현을 해야함 그럼 커스텀이 어느 정도 들어간다는걸 알 수 있었음

//
//  MainTabBarController.swift
//  HOLIX_iOS
//
//  Created by 정정욱 on 5/13/25.
//

import UIKit

final class MainTabBarController: UITabBarController {

    // MARK: - Lifecycle
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupTabBar()
        setupTabBarAppearance()
        setupViewControllers()
    }

    // MARK: - Setup
    /// 추후 소은이 Font 리팩토링 끝나면 setupTabBarAppearance 수정 해야함
    
    private func setupTabBar() {
        tabBar.backgroundColor = .white
        tabBar.isTranslucent = false
    }

    private func setupTabBarAppearance() {
        let appearance = UITabBarItem.appearance()

        appearance.setTitleTextAttributes([
            .font: UIFont.pretendard(size: 11, weight: .Bold),
            .foregroundColor: UIColor.gray
        ], for: .normal)

        appearance.setTitleTextAttributes([
            .font: UIFont.pretendard(size: 11, weight: .Bold),
            .foregroundColor: UIColor.systemBlue
        ], for: .selected)
    }

    private func setupViewControllers() {
        let homeVC = ViewController()
        homeVC.tabBarItem = UITabBarItem(
            title: "홈",
            image: IconLiterals.ic_home.withRenderingMode(.alwaysOriginal),
            selectedImage: IconLiterals.ic_home_active.withRenderingMode(.alwaysOriginal)
        )

        let clubVC = ViewController()
        clubVC.tabBarItem = UITabBarItem(
            title: "내 클럽",
            image: IconLiterals.ic_my.withRenderingMode(.alwaysOriginal),
            selectedImage: IconLiterals.ic_my_active.withRenderingMode(.alwaysOriginal)
        )

        let notificationVC = ViewController()
        notificationVC.tabBarItem = UITabBarItem(
            title: "알림",
            image: IconLiterals.ic_alert.withRenderingMode(.alwaysOriginal),
            selectedImage: IconLiterals.ic_alert_active.withRenderingMode(.alwaysOriginal)
        )

        let profileVC = ViewController()
        profileVC.tabBarItem = UITabBarItem(
            title: "프로필",
            image: IconLiterals.ic_profile.withRenderingMode(.alwaysOriginal),
            selectedImage: IconLiterals.ic_profile_active.withRenderingMode(.alwaysOriginal)
        )
	
	// 이 부분이 컨트롤러들을 등록 하는 부분인데 네비게이션 설정 까지 같이 해준 거임
        self.viewControllers = [
            UINavigationController(rootViewController: homeVC),
            UINavigationController(rootViewController: clubVC),
            UINavigationController(rootViewController: notificationVC),
            UINavigationController(rootViewController: profileVC)
        ]
    }
}

UITabBarItem.appearance()는 왜 전역 적용되나요?

UIKit의 appearance()는 UIKit 전역의 스타일 설정 시스템

let appearance = UITabBarItem.appearance()

이렇게 하면 앱 전체의 모든 UITabBarItem에 동일하게 스타일이 적용됨

내부 동작 요약:

어떤 경우 사용하나?