docs/docsets/FoldingCell.docset/Contents/Resources/Documents/index.html
The iPhone mockup available here.
Just add the FoldingCell.swift file to your project.
or use CocoaPods with Podfile: ruby pod 'FoldingCell', '~> 0.8.1'
or Carthage users can simply add Mantle to their Cartfile: github "Ramotion/folding-cell"
Create a new cell inheriting from FoldingCell
Add a UIView to your cell in your storyboard or nib file, inheriting from RotatedView. Connect the outlet from this view to the cell property foregroundView. Add constraints from this view to the superview, as in this picture:
(constants of constraints may be different). Connect the outlet from this top constraint to the cell property foregroundViewTop . (This view will be shown when the cell is in its normal state).
containerView. Add constraints from this view to the superview like in the picture:(constants of constraints may be different). Connect the outlet from this top constraint to the cell property containerViewTop. (This view will be shown when the cell is opened)
Your result should be something like this picture:
Demonstration adding constraints for foregroundView, containerView
@IBInspectable var itemCount: NSInteger property is a count of folding (it IBInspectable you can set in storyboard). range 2 or greater. Default value is 2Ok, we’ve finished configuring the cell.
5.1) Add constants: swift let kCloseCellHeight: CGFloat = *** // equal or greater foregroundView height let kOpenCellHeight: CGFloat = *** // equal or greater containerView height 5.2) Add property
var cellHeights = CGFloat
create in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
for _ in 0...kRowsCount {
cellHeights.append(kCloseCellHeight)
}
}
5.3) Override method: swift override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return cellHeights[indexPath.row] }
5.4) Added code to method: “` swift override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath) as! FoldingCell
var duration = 0.0
if cellHeights[indexPath.row] == kCloseCellHeight { // open cell
cellHeights[indexPath.row] = kOpenCellHeight
cell.selectedAnimation(true, animated: true, completion: nil)
duration = 0.5
} else {// close cell
cellHeights[indexPath.row] = kCloseCellHeight
cell.selectedAnimation(false, animated: true, completion: nil)
duration = 1.1
}
UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseOut, animations: { () -> Void in
tableView.beginUpdates()
tableView.endUpdates()
}, completion: nil)
}
5.5) Control if the cell is open or closed
``` swift
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if cell is FoldingCell {
let foldingCell = cell as! FoldingCell
if cellHeights![indexPath.row] == kCloseCellHeight {
foldingCell.selectedAnimation(false, animated: false, completion:nil)
} else {
foldingCell.selectedAnimation(true, animated: false, completion: nil)
}
}
}
// durations count equal it itemCount
let durations = [0.33, 0.26, 0.26] // timing animation for each view
return durations[itemIndex]
}
#### if don't use storyboard and xib files
Create foregroundView and containerView from code (steps 2 - 3) look example:
[Folding-cell-programmatically](https://github.com/ober01/Folding-cell-programmatically)
## Licence
Folding cell is released under the MIT license.
See [LICENSE](./LICENSE) for details.
## About
The project maintained by [app development agency](https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)
See our other [open-source projects](https://github.com/ramotion) or [hire](https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.
[](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)
[](https://twitter.com/ramotion)
© 2016 AlexKalinkin. All rights reserved. (Last updated: 2016-06-15)
Generated by jazzy ♪♫ v0.5.0, a Realm project.