ios - xlpagertabstrip 一些未完全显示的标签

标签 ios swift xcode xlpagertabstrip

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

enter image description here

正如您所看到的,最后一个选项卡“Arabic”没有完全显示。

这是我的代码:

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.
}

但这只会改变它的字体大小,如果我点击它......

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

最佳答案

but i have a problem that the text is bigger than the width and it got cut from both side

您可以尝试lineBreakMode

label.lineBreakMode = .ByCharWrapping

了解更多关于LineBreakMode的信息.

关于ios - xlpagertabstrip 一些未完全显示的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52697877/

相关文章:

ios - SceneKit 转换值,它们是如何实现的?

ios - Xcode : This coder requires that replaced objects be returned from initWithCoder:

ios - 使用 ObservableObject 时 View 不会更新

ios - 缺少 cocoa pod 构建阶段

iOS xcode 麦克风音量检测?

ios - 我们可以将 IBOutlets 归入一个类别吗?

ios - 使用 NSURLConnection 异步下载 UITableView 的图像

ios - 使用 OutputStream 写入时如何检查是否成功?

ios - 通过 UICollectionView 单元格快速枚举 - Swift

ios - 如何在降压构建上运行 xcconfig