rechsteiner / Parchment

A paging view with a highly customizable menu ✨
MIT License
3.35k stars 417 forks source link

please support indicator fixed width #687

Open chunxige opened 1 year ago

Toj-dev commented 3 months ago

I want it too. please

Toj-dev commented 3 months ago

我是写一个子类继承PagingIndicatorView, 设置 options.indicatorColor = .clear 子类里包含一个子视图固定宽度

class SLPagingIndicatorView: PagingIndicatorView {

static var indicatorWidth: CGFloat = 24.ui_mscale
static var indicatorHeight: CGFloat = 2
static var indicatorColor = "#FF9900".to_color

private lazy var indicatorView: UIView = {
    let view = UIView()
    view.backgroundColor = Self.indicatorColor
    return view
}()

override init(frame: CGRect) {
    super.init(frame: frame)
    addSubview(indicatorView)
    indicatorView.snp.makeConstraints { make in
        make.center.equalToSuperview()
        make.height.equalTo(Self.indicatorHeight)
        make.width.equalTo(Self.indicatorWidth)
    }
}

required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

}