【问题标题】:Selected TabBar item height选定的 TabBar 项高度
【发布时间】:2016-07-10 12:21:32
【问题描述】:

我正在制作一个在 UITabBarController 中带有标签栏的应用程序。

我想让所选项目具有不同的(自定义)颜色,并且比其他项目高一点。

我使用背景图像将标签栏的背景设置为自定义颜色:

UITabBar.appearance().backgroundImage = UIImage(named: "TabBarBlue")
UITabBar.appearance().tintColor = UIColor.whiteColor()

我在网上搜索过,但没有找到好的解决方案,这里有人知道如何实现吗?

【问题讨论】:

    标签: ios xcode swift ios9 tabbar


    【解决方案1】:

    只需将框架高度设置为高 15 个点即可解决此问题:

    let numberOfItems = CGFloat(tabBar.items!.count)
    let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height + 15)
    tabBar.selectionIndicatorImage = UIImage.imageWithColor(UIColor(netHex:0xe00628), size: tabBarItemSize).resizableImageWithCapInsets(UIEdgeInsetsZero)
    

    【讨论】:

      猜你喜欢
      • 2012-10-28
      • 1970-01-01
      • 2020-10-14
      • 1970-01-01
      • 2017-10-31
      • 1970-01-01
      • 2011-10-27
      • 2021-08-22
      • 2019-05-19
      相关资源
      最近更新 更多