LvJianfeng / LLCycleScrollView

Swift - 轮播图,文本轮播,支持左右箭头
MIT License
371 stars 65 forks source link

让titlelable的文字居中显示怎么设置? #59

Closed slash130 closed 5 years ago

slash130 commented 5 years ago

我尝试在LLCycleScrollViewCell里修改setupTitleLabel添加文字居中设置,添加后不生效。谁知道怎么设置居中显示?

LvJianfeng commented 5 years ago

@slash130 莫慌,首先目前只开放了设置leading。 当然,你直接改LLCycleScrollViewCell.swift文件,#106-setupTitleLabel是可以的。

    // Setup Title
    fileprivate func setupTitleLabel() {
        titleLabel = UILabel.init()
        titleLabel.isHidden = true
        titleLabel.textColor = titleLabelTextColor
        titleLabel.numberOfLines = titleLines
        titleLabel.font = titleFont
        titleLabel.backgroundColor = UIColor.clear
        titleLabel.textAlignment = .center
        titleBackView.addSubview(titleLabel)
    }

你确认下。

slash130 commented 5 years ago

我就是这样添加的设置,然后在模拟器里运行没有效果,还是居左。

    self.lbview.imagePaths = imagesURLStrings
    self.lbview.titles = titles

    self.lbview.autoScrollTimeInterval = 2.5
    self.lbview.imageViewContentMode = .scaleToFill
    if imagesURLStrings.count == 1 {
        self.lbview.customPageControlStyle = .none
    } else {
        self.lbview.customPageControlStyle = .fill
    }
    self.lbview.pageControlPosition = .center
    self.lbview.isAddingPercentEncodingForURLString = true
    self.lbview.delegate = self

这是调用代码。

LvJianfeng commented 5 years ago

@slash130 我糗糗你的初始化代码,你也可以运行下我的Demo。

slash130 commented 5 years ago

怪了,在你的demo里添加居中生效,在我的项目里修改pod里的代码不生效。

LvJianfeng commented 5 years ago

@slash130 pod 你确定是修改后的代码了?

slash130 commented 5 years ago

找到问题原因了,是xcode设置的问题导致修改pod里的代码不生效。

slash130 commented 5 years ago

还有个问题,在pod代码里修改cellHeight好像没变化了,我记的以前是可以通过调整这个参数修改文字框的高度的。

LvJianfeng commented 5 years ago

@slash130 cell.titleLabelHeight = cellHeight仅支持了单独的文本轮播了,如果需要你可以考虑进行源码修改,在collectionView的数据源代理中cellForItemAt.

slash130 commented 5 years ago

嗯 我修改源码后ok了

LvJianfeng commented 5 years ago

@slash130 嗯,后续我会更新新版本。