我在我的应用程序中使用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.
}
但是这只会改变它的字体大小,如果我把它标记了...
该如何解决?我希望它从一开始就可以完全显示并适合单元格的宽度..
答案 0 :(得分:0)
但是我有一个问题,就是文本大于宽度,并且从两侧都切掉了
您可以尝试lineBreakMode
label.lineBreakMode = .ByCharWrapping
详细了解LineBreakMode。