IGStoriesView
摘要
IGStoriesView 是一个具有许多功能和易于集成的简单故事卡片可重用组件。
开始使用
要开始使用,您需要设置 Cocoapods 并安装 IGStoriesView
pod 'IGStoriesView'
支持的平台
.iOS(.v12) 及以上
如何在 UIViewController 中集成
1- 在您的 xib 或 storyboard 中添加对 IGStoriesView
的引用
@IBOutlet weak var storyCardView: IGStoriesCardView!
2- 传递类型为 IGStoriesViewModel
的故事视图模型列表
public struct IGStoriesViewModel {
var image: String?
var name: String?
var isSeen: Bool?
var userId: String?
}
然后将它添加到您的 VC 中
storyCardView.storiesViewModels = allStories
storyCardView.delegate = self
要监听打开一个故事的动作,您应该设置类型为 IGStoriesCollectionViewActionsDelegate
的代理。
示例
extension ViewController: IGStoriesCollectionViewActionsDelegate {
func collectionView(_ collectionView: UICollectionView, didSelect userId: String?) {
// present your story here
}
}
这就是您应该看到的所有内容。