Swift를 사용하여 TabBar 선택 시 색상 및 글꼴 변경

3071 단어 SwiftiOS

Swift로 TabBar가 선택한 색상과 글꼴을 변경하는 방법


TabBarController.swift
override func viewDidLoad() {
        super.viewDidLoad()
        let font:UIFont! = UIFont(name:"HelveticaNeue-Bold",size:10)
        let selectedAttributes:NSDictionary! = [NSFontAttributeName : font, NSForegroundColorAttributeName : UIColor(red:0.13, green:0.55, blue:0.83, alpha:1.0)]

      UITabBarItem.appearance().setTitleTextAttributes(selectedAttributes, forState: UIControlState.Selected)

        UITabBar.appearance().tintColor = UIColor(red: 0.13, green: 0.55, blue: 0.83, alpha: 1.0)
}

이렇게 하면 간단하게 색깔을 바꿀 수 있다.

좋은 웹페이지 즐겨찾기