/ / Tittle показує більше в UITabBarController в iOS 7 програмно - ios, swift, uitabbarcontroller, uitabbar

Tittle показує більше в UITabBarController в iOS 7 програмним шляхом - ios, swift, uitabbarcontroller, uitabbar

Я реалізував UITabBarController програмно. Заголовок viewControllers відображається більшим і обрізаним. Ось вихідний код:

    var tab: UITabBarController = UITabBarController()
tab.tabBar.translucent = false

var homeVC: UINavigationController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() as UINavigationController
homeVC.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "icon-home"), tag: 0)

var messagesNavC: UINavigationController = UIStoryboard(name: "Messages", bundle: nil).instantiateInitialViewController() as UINavigationController
messagesNavC.tabBarItem = UITabBarItem(title: "Messages", image: UIImage(named: "icon-messages"), tag: 1)

var quotesRequests: UINavigationController = UINavigationController(rootViewController: UIStoryboard(name: "QuotesRequests", bundle: nil).instantiateViewControllerWithIdentifier("RSQuoteRequestsViewController") as RSQuoteRequestsViewController) as UINavigationController
quotesRequests.tabBarItem = UITabBarItem(title: "Quotes", image: UIImage(named: "icon-quotes"), tag: 2)

var myAccount: UINavigationController = UIStoryboard(name: "MyAccount", bundle: nil).instantiateInitialViewController() as UINavigationController
myAccount.tabBarItem = UITabBarItem(title: "Account", image: UIImage(named: "icon-account"), tag: 3)

var helpVC: UINavigationController = UIStoryboard(name: "Help", bundle: nil).instantiateInitialViewController() as UINavigationController
helpVC.tabBarItem = UITabBarItem(title: "Help", image: UIImage(named: "icon-help"), tag: 4)

tab.viewControllers = [homeVC, quotesRequests, messagesNavC, myAccount, helpVC]

Ось скріншот, як він виглядає.

введіть опис зображення тут Будь ласка, допоможіть. Заздалегідь спасибі.

Відповіді:

2 для відповіді № 1

Спробуйте змінити свій розмір

let appearance = UITabBarItem.appearance()
let attributes = [NSFontAttributeName:UIFont(name: "American Typewriter",size: 20)]
appearance.setTitleTextAttributes(attributes, forState: .Normal)

Або ви також можете спробувати це:

 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], NSFontAttributeName, nil] forState:UIControlStateNormal];