【问题标题】:iCarousel - how do I turn off infinite scroll?iCarousel - 如何关闭无限滚动?
【发布时间】:2022-01-22 02:58:20
【问题描述】:

我只是使用iCarousel 库在轮播中显示项目。

但是当我向左滑动并拥有例如 5 个项目时,它会旋转几次。当currentIndex为0时如何防止向左旋转,currentIndex设置为最大值时如何防止向右旋转。

这就是我定义轮播及其数据源的方式:

let carousel: iCarousel = {
    let view = iCarousel()
    view.type = .invertedCylinder
    view.perspective = -0.0025
    view.clipsToBounds = true
    return view
}()

// MARK: - iCarouselDataSource

func numberOfItems(in _: iCarousel) -> Int {
    viewModel.cards.count
}

func carousel(_: iCarousel, viewForItemAt index: Int, reusing view: UIView?) -> UIView {
    let view = view as? UIImageView ?? mainView.cardImageViewForCarousel
    view.image = nil
    if let url = viewModel.backImageUrl(atIndex: index) {
        view.setImage(with: url)
    }
    return view
}

func carousel(_: iCarousel, valueFor option: iCarouselOption, withDefault value: CGFloat) -> CGFloat {
    if option == .visibleItems {
        return 3
    } else if option == .spacing {
        return value * 1.1
    } else if option == .count {
        return 7
    }
    return value
}

【问题讨论】:

    标签: ios swift icarousel


    【解决方案1】:

    wrapEnabled 属性设置为false 应该会禁用该功能。

    【讨论】:

    • @BartłomiejSemańczyk 如果它解决了您的问题,那么您应该将其标记为已接受;)
    猜你喜欢
    • 1970-01-01
    • 2013-01-12
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-13
    • 2017-12-10
    相关资源
    最近更新 更多