【问题标题】:xlpagertabstrip some labels not fully displayedxlpagertabstrip 一些标签没有完全显示
【发布时间】:2019-03-12 20:46:21
【问题描述】:

我在我的应用程序中使用 XLpagertabstrip .. 但我有一个问题是文本大于宽度并且它被从两侧切割.. 如下图:

你可以看到最后一个标签是 المواجهات المباشرة 没有完全显示..

这是我的代码:

override func viewDidLoad() {
    super.viewDidLoad()

    containerView.isScrollEnabled = false
    containerView.delegate = self

    self.settings.style.buttonBarBackgroundColor = UIColor.clear
    self.settings.style.buttonBarItemBackgroundColor = UIColor.clear
    self.settings.style.selectedBarBackgroundColor = UIColor.clear
    self.settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 7)
    self.settings.style.selectedBarHeight = 1.0
    self.settings.style.buttonBarMinimumLineSpacing = 0.1
    self.settings.style.buttonBarItemTitleColor = UIColor.white
    self.settings.style.buttonBarItemsShouldFillAvailableWidth = true
    self.settings.style.buttonBarLeftContentInset = 0
    self.settings.style.buttonBarRightContentInset = 0
    self.settings.style.selectedBarHeight = 1.0

    changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
        guard changeCurrentIndex == true else { return }
        //oldCell?.label.adjustsFontSizeToFitWidth = true
        //newCell?.label.adjustsFontSizeToFitWidth = true
        oldCell?.label.textColor = UIColor.white
        newCell?.label.textColor = UIColor.white
        oldCell?.label.font = UIFont(name: "AJannatLT", size: 14)!
        newCell?.label.font = UIFont(name: "AJannatLT", size: 14)
        newCell?.label.lineBreakMode = .byCharWrapping
        oldCell?.label.lineBreakMode = .byCharWrapping
        self?.buttonBarView.selectedBar.backgroundColor = UIColor.white
    }

    getMatchInfo()

    self.navigationController?.navigationBar.topItem?.title = " "

    // Do any additional setup after loading the view.
}

但这只会在我选中它时改变它的字体大小...

如何解决这个问题?我希望它从一开始就完全显示并适合单元格的宽度..

【问题讨论】:

  • 你是如何创建单元格的?它是具有自己的类的自定义单元格吗?
  • @Tobi 它由 xlpagertabstrip 创建.. 我没有创建或自定义它.. 我使用库的默认值
  • 哦,好吧,太好了。
  • 尝试设置 label.numberOfLines = 0
  • @George 没用 :(

标签: ios swift xcode xlpagertabstrip


【解决方案1】:

但我有一个问题,文本比宽度大,而且从两边都被剪掉了

你可以试试lineBreakMode

label.lineBreakMode = .ByCharWrapping

阅读更多关于LineBreakMode的信息。

【讨论】:

  • 很遗憾得到了与我发布的屏幕截图相同的结果:(
  • 尝试将 super.viewDidLoad 移到方法的底部,听起来很奇怪,但可以工作
  • 遗憾的是它没有:(
猜你喜欢
  • 2019-12-24
  • 1970-01-01
  • 2015-08-05
  • 2011-12-09
  • 1970-01-01
  • 1970-01-01
  • 2019-08-20
  • 1970-01-01
  • 2011-10-08
相关资源
最近更新 更多