@@ -10,9 +10,9 @@
[](https://github.com/Carthage/Carthage)
[](https://github.com/igrigorik/ga-beacon)
## About
This project is maintained by Ramotion, an agency specialized in building dedicated engineering teams and developing custom software.<br><br> [ Contact our team ]( https://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell-contact-us ) and we’ ll help you work with the best engineers from Eastern Europe.
This project is maintained by Ramotion, Inc.<br>
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.<br><br>**Looking for developers for your project?** [[▶︎CONTACT OUR TEAM◀︎ ](http://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell-contact-us/#Get_in_Touch )]
[](https://dribbble.com/shots/2121350-Delivery-Card)
@@ -29,16 +29,18 @@ Just add the FoldingCell.swift file to your project.
or use [CocoaPods ](https://cocoapods.org ) with Podfile:
``` ruby
pod 'FoldingCell'
pod 'FoldingCell' '~> 1.0.0' swift 2.2
pod 'FoldingCell' '~> 2.0.1' swift 3
` ``
or [Carthage](https://github.com/Carthage/Carthage) users can simply add Mantle to their ` Cartfile`:
` ``
github "Ramotion/folding-cell" "~> 1.0.0" swift 2.2
github "Ramotion/folding-cell"
github "Ramotion/folding-cell" "~> 2.0.0" swift 3
` ``
or just drag and drop FoldingCell.swift file to your project
## Solution

## Usage
@@ -76,24 +78,17 @@ Ok, 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
fileprivate struct C {
struct CellHeight {
static let close: CGFloat = *** // equal or greater foregroundView height
static let open: CGFloat = *** // equal or greater containerView height
}
}
` ``
5.2) Add property
5.2) Add property for calculate cells height
` `` swift
var cellHeights = [CGFloat]()
` ``
create in viewDidLoad:
` `` swift
override func viewDidLoad() {
super.viewDidLoad()
for _ in 0...kRowsCount {
cellHeights.append(kCloseCellHeight)
}
}
var cellHeights = (0..<CELLCOUNT).map { _ in C.CellHeight.close }
` ``
5.3) Override method:
@@ -106,7 +101,9 @@ Ok, we've finished configuring the cell.
5.4) Added code to method:
` `` swift
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let c ell = tableView.cellForRowAtIndexPath(indexPath) as! FoldingCell
guard case let cell as FoldingC ell = tableView.cellForRowAtIndexPath(indexPath) else {
return
}
var duration = 0.0
if cellHeights[indexPath.row] == kCloseCellHeight { // open cell
@@ -119,7 +116,7 @@ Ok, we've finished configuring the cell.
duration = 1.1
}
UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseOut, animations: { () -> Void in
UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseOut, animations: { _ in
tableView.beginUpdates()
tableView.endUpdates()
}, completion: nil)
@@ -129,10 +126,8 @@ Ok, we've finished configuring the cell.
` `` swift
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if cell i s FoldingCell {
let foldingCell = cell as! FoldingCell
if cellHeights![indexPath.row] == kCloseCellHeight {
if case let cell a s FoldingCell = cell {
if cellHeights![indexPath.row] == C.cellHeights.close {
foldingCell.selectedAnimation(false, animated: false, completion:nil)
} else {
foldingCell.selectedAnimation(true, animated: false, completion: nil)