首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iCarousel -如何关闭无限滚动?

iCarousel -如何关闭无限滚动?
EN

Stack Overflow用户
提问于 2021-12-20 13:41:58
回答 1查看 136关注 0票数 -1

我只是使用iCarousel库在旋转木马中显示项目。

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

这就是我如何定义我的旋转木马及其数据源的方式:

代码语言:javascript
复制
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
}
EN

回答 1

Stack Overflow用户

发布于 2021-12-20 13:48:38

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70422724

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档