https://github.com/Ramotion/expanding-collection
A card peek/pop controller.
Ramotion, Inc 出品.
专注于移动应用程序和网站的自定义 UI 的设计和编码
The iPhone mockup available here.
只需将 Source 文件夹添加到您的项目.
或者使用 CocoaPods , Podfile 文件中添加以下一行:
pod 'expanding-collection', '~> 1.0.3' swift 3 pod 'expanding-collection', '~> 0.3.2' swift 2
or Carthage Cartfile
文件添加以下一行:
github "Ramotion/expanding-collection"
import expanding_collection
Create UICollectionViewCell inherit from BasePageCollectionCell
(recommend create cell with xib file)
Adding FrontView
@IBOutlet weak var frontContainerView: UIView!
@IBOutlet weak var frontConstraintY: NSLayoutConstraint!
@IBOutlet weak var backContainerView: UIView!
, @IBOutlet weak var backConstraintY: NSLayoutConstraint!
)tag = 101
for any FrontView.subviews
this view will be hidden during the transition animationCreate a UIViewController inheriting from ExpandingViewController
Register Cell and set Cell size:
override func viewDidLoad() { itemSize = CGSize(width: 214, height: 264) super.viewDidLoad() // register cell let nib = UINib(nibName: "NibName", bundle: nil) collectionView?.registerNib(nib, forCellWithReuseIdentifier: "CellIdentifier") }
extension YourViewController { override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return items.count } override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CellIdentifier"), forIndexPath: indexPath) // configure cell return cell } }
override func viewDidLoad() { itemSize = CGSize(width: 214, height: 264) super.viewDidLoad() // register cell let nib = UINib(nibName: "CellIdentifier", bundle: nil) collectionView?.registerNib(nib, forCellWithReuseIdentifier: String(DemoCollectionViewCell)) }
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { cell.cellIsOpen(!cell.isOpened) }
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) func scrollViewDidEndDecelerating(scrollView: UIScrollView)
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) { super.collectionView(collectionView: collectionView, willDisplayCell cell: cell, forItemAtIndexPath indexPath: indexPath) // code } func scrollViewDidEndDecelerating(scrollView: UIScrollView) { super.scrollViewDidEndDecelerating(scrollView: scrollView) // code }
Create a UITableViewController inheriting from ExpandingTableViewController
Set header height default 236
override func viewDidLoad() { super.viewDidLoad() headerHeight = *** }
if cell.isOpened == true { let vc: YourTableViewCOntroller= // ... create view controller pushToViewController(vc) }
popTransitionAnimation()