目录
目录README.md

StackedItemsCarousel

A carousel of stacked items (such as photos) as seen in iMessage

What?

iMessage on iOS 15 shows multiple photos in a carousel of stacked items that the user can swipe thru. This is a reimplementation of that view.

https://user-images.githubusercontent.com/168214/138356900-df2b2822-6724-4f09-be69-a216aa972f39.mp4

How to use?

StackedItemsLayout

The carousel has been implemented as a custom UICollectionViewLayout: StackedItemsLayout. You can use this layout directly in a UICollectionView that uses paging:

let collectionView = UICollectionView(frame: .zero, collectionViewLayout: StackedItemsLayout())
collectionView.backgroundColor = nil
collectionView.alwaysBounceHorizontal = true
collectionView.clipsToBounds = false
collectionView.isPagingEnabled = true

//  configure the collection view as any other collection view 

StackedItemsView

You can also use the convenience wrapper view, StackedItemsView. This is a generic view that takes an ItemType and CellType as generic parameters and handles the collection view for you:

let stackedItemsView = StackedItemsView<UIColor, YourSubclassOfUICollectionViewCell>()

stackedItemsView.items = [.red, .blue, .brown, .green, .orange, .purple, .yellow, .gray, .cyan, .magenta]
stackedItemsView.configureItemHandler = { item, cell in
    // configure your cell here - it already has some shadow and corner radius parameters set on
    // the cell itself.
}
stackedItemsView.selectionHandler = { [weak self] item, index in
    // handle item selection here
}
view.addSubview(stackedItemsView)
关于
56.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号