From ba3f58f953a5e483955b3debbeeb9c361d230a12 Mon Sep 17 00:00:00 2001 From: WenchaoD Date: Tue, 2 Oct 2018 07:32:13 +0800 Subject: [PATCH] Add 'cellForItem(at:)' func to FSPagerView. --- Sources/FSPagerView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index f3370e6..13e7f20 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -528,6 +528,16 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega return indexPath.item } + /// Returns the visible cell at the specified index. + /// + /// - Parameter index: The index that specifies the position of the cell. + /// - Returns: The cell object at the corresponding position or nil if the cell is not visible or index is out of range. + @objc(cellForItemAtIndex:) + open func cellForItem(at index: Int) -> FSPagerViewCell? { + let indexPath = self.nearbyIndexPath(for: index) + return self.collectionView.cellForItem(at: indexPath) as? FSPagerViewCell + } + // MARK: - Private functions fileprivate func commonInit() {