Ramotion / expanding-collection
- воскресенье, 29 мая 2016 г. в 03:13:21
Swift
ExpandingCollection is a card peek/pop controller
The iPhone mockup available here.
Just add the Source folder to your project.
or use CocoaPods with Podfile:
pod 'expanding-collection', '~> 0.0.2'
import expanding_collection
1) Create UICollectionViewCell inherit from BasePageCollectionCell
(recommend create cell with xib file)
2) Adding FrontView
@IBOutlet weak var frontContainerView: UIView!
add width, height, centerX and centerY constraints (width and height constranints must equal cellSize)
@IBOutlet weak var frontConstraintY: NSLayoutConstraint!
3) Adding BackView
@IBOutlet weak var backContainerView: UIView!
, @IBOutlet weak var backConstraintY: NSLayoutConstraint!
)4) Cell example DemoCell
tag = 101
for any FrontView.subviews
this view will be hidden during the transition animation1) Create a UIViewController inheriting from ExpandingViewController
2) Register Cell and set Cell size:
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))
}
3) Add UICollectionViewDataSource methods
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
}
}
4) Open Cell animation
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)
}
1) Create a UITableViewController inheriting from ExpandingTableViewController
2) Set header height default 236
override func viewDidLoad() {
super.viewDidLoad()
headerHeight = ***
}
3) Call the push method in YourViewController to YourTableViewController
if cell.isOpened == true {
let vc: YourTableViewController = // ... create view controller
pushToViewController(vc)
}
4) For back transition use popTransitionAnimation()
Epanding collection is released under the MIT license. See LICENSE for details.
The project maintained by app development agency Ramotion Inc. See our other open-source projects or hire us to design, develop, and grow your product.