【问题标题】:Adding Label underneath UIBarButtonItem like in UITabBarItem [duplicate]在 UIBarButtonItem 下添加标签,如在 UITabBarItem [重复]
【发布时间】:2017-05-13 18:33:10
【问题描述】:

基本上我想用UIBarButton实现这个目标:

我尝试使用setTitle,但最终得到了这样的结果:

【问题讨论】:

    标签: ios swift uibarbuttonitem


    【解决方案1】:

    创建您的自定义导航栏 - 将 UIView 添加到视图控制器的顶部,并在其左角添加 UIButton。并在按钮下方添加标签。

    【讨论】:

      【解决方案2】:

      可以通过使用带有 UIBarButtonItem 的自定义视图来完成。像这样。

      斯威夫特

      let image = UIImage.init(named: "image_name")
      let button = UIButton.init(type: .custom)
      button.frame = CGRect.init(x: 0, y: 0, width: 100, height: 40)
      button.setBackgroundImage(image, for: .normal)
      button.setTitle("title", for: .normal)
      let barButtonItem = UIBarButtonItem.init(customView: button)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-07-22
        • 2015-11-10
        • 1970-01-01
        • 2020-06-27
        • 1970-01-01
        • 2014-11-13
        • 1970-01-01
        相关资源
        最近更新 更多