Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
980dc63dd9 | ||
|
|
a0021618de | ||
|
|
7a931cb414 | ||
|
|
ab56f9ad83 | ||
|
|
47397e60c6 | ||
|
|
63e9ff9410 | ||
|
|
6b95f91f86 | ||
|
|
c439f9af9b | ||
|
|
5bd466425f | ||
|
|
4b152e7901 | ||
|
|
756c665759 | ||
|
|
29f151dcef |
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FoldingCell'
|
||||
s.version = '2.0.0'
|
||||
s.version = '2.0.2'
|
||||
s.summary = 'UITableViewCell with folding animation.'
|
||||
s.homepage = 'https://github.com/Ramotion/folding-cell'
|
||||
s.license = 'MIT'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="0cn-rv-Emg">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
|
||||
@@ -217,9 +217,13 @@ open class FoldingCell: UITableViewCell {
|
||||
let itemHeight = (contSize.height - 2 * forgSize.height) / CGFloat(itemCount - 2)
|
||||
|
||||
if itemCount == 2 {
|
||||
// decrease containerView height or increase itemCount
|
||||
assert(contSize.height - 2 * forgSize.height == 0, "contanerView.height too high")
|
||||
}
|
||||
// decrease containerView height or increase itemCount
|
||||
assert(contSize.height - 2 * forgSize.height == 0, "contanerView.height too high")
|
||||
}
|
||||
else{
|
||||
// decrease containerView height or increase itemCount
|
||||
assert(contSize.height - 2 * forgSize.height >= itemHeight, "contanerView.height too high")
|
||||
}
|
||||
// decrease containerView height or increase itemCount
|
||||
assert(contSize.height - 2 * forgSize.height >= itemHeight, "contanerView.height too high")
|
||||
|
||||
@@ -310,7 +314,7 @@ open class FoldingCell: UITableViewCell {
|
||||
func durationSequence(_ type: AnimationType)-> [TimeInterval] {
|
||||
var durations = [TimeInterval]()
|
||||
for index in 0..<itemCount-1 {
|
||||
let duration = animationDuration(index, type: .open)
|
||||
let duration = animationDuration(index, type: type)
|
||||
durations.append(TimeInterval(duration / 2.0))
|
||||
durations.append(TimeInterval(duration / 2.0))
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -28,17 +28,16 @@ The [iPhone mockup](https://store.ramotion.com/product/iphone-6-mockups?utm_sour
|
||||
Just add the FoldingCell.swift file to your project.
|
||||
|
||||
or use [CocoaPods](https://cocoapods.org) with Podfile:
|
||||
``` ruby
|
||||
pod 'FoldingCell'
|
||||
```
|
||||
pod 'FoldingCell' '~> 2.0.2'
|
||||
|
||||
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 +75,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 +98,9 @@ Ok, we've finished configuring the cell.
|
||||
5.4) Added code to method:
|
||||
``` swift
|
||||
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
let cell = tableView.cellForRowAtIndexPath(indexPath) as! FoldingCell
|
||||
guard case let cell as FoldingCell = tableView.cellForRowAtIndexPath(indexPath) else {
|
||||
return
|
||||
}
|
||||
|
||||
var duration = 0.0
|
||||
if cellHeights[indexPath.row] == kCloseCellHeight { // open cell
|
||||
@@ -119,7 +113,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 +123,8 @@ Ok, we've finished configuring the cell.
|
||||
``` 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 {
|
||||
if case let cell as FoldingCell = cell {
|
||||
if cellHeights![indexPath.row] == C.cellHeights.close {
|
||||
foldingCell.selectedAnimation(false, animated: false, completion:nil)
|
||||
} else {
|
||||
foldingCell.selectedAnimation(true, animated: false, completion: nil)
|
||||
|
||||
Reference in New Issue
Block a user