Compare commits

...
61 Commits
Author SHA1 Message Date
Alex K 3335c26e78 converted to swift 4.2 2018-09-17 10:32:37 +03:00
Alex K 27d2bc7a62 update podspec 2018-09-17 10:30:41 +03:00
Alex 882a279d56 Merge pull request #157 from PeterStaev/nativescript
Export important APIs to ObjC
2018-09-10 09:51:04 +03:00
Alex K 959c31e2c5 add firs test create folding cell 2018-09-06 14:45:13 +03:00
Peter Staev 8777fc4410 expose enum to ObjC 2018-09-03 16:31:56 +03:00
Peter Staev 27b748230b export animationDuration to ObjC 2018-09-03 16:23:36 +03:00
Peter Staev f887081e42 export isUnfolded to ObjC 2018-09-03 16:23:25 +03:00
Peter Staev 370b3dae99 expose commonInit to ObjC 2018-08-31 19:08:20 +03:00
Alex K d6e2b6cebb test init 2018-08-30 17:42:21 +03:00
Alex K a102990f70 add Tests target 2018-08-24 10:58:25 +03:00
Alex K 78f726da6b update podspec 2018-08-17 09:59:14 +03:00
Alex K de2815310c code improve 2018-07-31 09:20:27 +03:00
Alex K 79ebfdad72 update podspec 2018-07-24 09:41:19 +03:00
Alex K 7fccf4465d increase deployment target 2018-07-24 09:39:25 +03:00
Alex K 10f2b4a593 Fixes #151 2018-07-17 11:22:06 +03:00
Alex K 2082c637fc update podspec 2018-07-11 14:19:27 +03:00
Alex K 1ad323db3e add constants for RotatedView 2018-07-11 14:16:40 +03:00
Alex K d0582c547e remove unused folders 2018-07-05 14:17:34 +03:00
Ramotion bab9a6cb13 Update README.md 2018-06-29 14:28:09 +03:00
Ramotion eb0fb13162 Update README.md 2018-06-26 10:03:34 +03:00
Alex K 28979e4c74 add mark 2018-06-19 14:07:28 +03:00
Alex K 9b169a7eeb rewrite constants in demo project 2018-06-13 09:20:05 +03:00
Ramotion e61613727f Update README.md 2018-06-05 09:11:16 +03:00
Ramotion b3c552e5e5 Update README.md 2018-05-29 11:52:45 +03:00
Ramotion acca9eeba7 Update README.md 2018-05-28 11:20:47 +03:00
Alex K 8c16530fbe code style improve 2018-05-21 10:09:39 +03:00
Alex K e4babdc1cc fix typo 2018-05-15 14:09:47 +03:00
Ramotion d2ebb37052 Update README.md 2018-05-09 10:24:56 +03:00
Alex K 8cfd463d24 add refresh control in demo project 2018-05-02 16:15:50 +03:00
Alex K 99d33faa5b update pod version 2018-05-02 16:05:23 +03:00
Alex K a4a918065d remove deprecated methods 2018-05-02 15:21:53 +03:00
Alex K dbaccb42b5 Merge branch 'master' of github.com:Ramotion/folding-cell 2018-05-02 15:15:43 +03:00
Alex K adbd6a608b Fixes #144 2018-05-02 15:15:34 +03:00
Ramotion f41fbfe98e Update README.md 2018-04-25 12:28:30 +03:00
Alex fd51a01d03 Update README.md 2018-04-23 09:26:46 +03:00
Ramotion 6f389b4850 Update README.md 2018-04-16 09:43:31 +03:00
Ramotion 9c1e834692 Update README.md 2018-04-09 09:44:30 +03:00
Ramotion da447982c8 Add files via upload 2018-04-09 09:43:35 +03:00
Alex K 816fe67543 update podspec 2018-04-02 10:21:06 +03:00
Alex K a191c4bc05 refactoring, remove guard with fatal error 2018-04-02 10:15:04 +03:00
Alex K cbe678277d update podspec 2018-03-27 16:37:34 +03:00
Alex K a760de74ee Fixes #126 make closeAnimation and opentAnimation methods public 2018-03-27 16:35:20 +03:00
Alex K 7d639d3332 update podspec 2018-03-27 16:32:23 +03:00
Alex K dc52176452 Fixes #62 2018-03-27 15:57:42 +03:00
Alex K 259e726146 Merge branch 'master' of github.com:Ramotion/folding-cell 2018-03-26 15:22:58 +03:00
Alex K 381fe89df9 Fix warning "The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings" 2018-03-26 15:22:49 +03:00
Alex 99d7b642c9 Update README.md 2018-03-20 10:08:19 +03:00
Alex d5aa310bd6 Update README.md
remove duplicate Carthage badge
2018-03-12 14:07:00 +03:00
Ramotion df05fb3424 Update README.md 2018-03-01 11:31:32 +03:00
Ramotion f144e16433 Update README.md 2018-02-28 14:42:44 +03:00
Alex K c9c710f485 Merge branch 'master' of github.com:Ramotion/folding-cell 2018-02-27 17:13:13 +03:00
Alex K 49611acdf9 remove warnings in demo project 2018-02-27 17:13:06 +03:00
Denis Pakhaliuk 283afd04b2 Update README.md 2018-02-21 12:05:05 +03:00
Alex K 7cf93be5b7 remove unused code 2018-02-20 16:16:33 +03:00
Alex K ae01474fa4 update podspec 2018-02-14 09:33:54 +03:00
Alex K 16fa9ad54d remove unused code 2018-02-14 09:32:32 +03:00
Alex K 40d58abd2b update podspec 2018-02-07 11:53:05 +03:00
Alex K 09c886e9a2 Fatal error message has improved. 2018-02-07 09:26:21 +03:00
Alex 814030c8cb Update README.md 2018-01-30 11:34:12 +03:00
Alex K fd985711a6 Merge branch 'refactoring'
# Conflicts:
#	FoldingCell/FoldingCell-Demo/Base.lproj/Main.storyboard
#	FoldingCell/FoldingCell.xcodeproj/project.pbxproj
#	FoldingCell/FoldingCell/FoldingCell.swift
2018-01-23 11:06:04 +03:00
Alex K f48738aeda fix demo project
remove unused code
2018-01-23 11:01:13 +03:00
15 changed files with 477 additions and 244 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FoldingCell'
s.version = '3.0.1'
s.version = '3.1.5'
s.summary = 'UITableViewCell with folding animation.'
s.homepage = 'https://github.com/Ramotion/folding-cell'
s.license = 'MIT'
@@ -28,7 +28,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
return true
}
}
@@ -39,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="0cn-rv-Emg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="0cn-rv-Emg">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
@@ -25,7 +25,7 @@
<objects>
<tableViewController storyboardIdentifier="MainTableViewController" id="0cn-rv-Emg" customClass="MainTableViewController" customModule="FoldingCell_Demo" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="667" sectionHeaderHeight="28" sectionFooterHeight="28" id="MwZ-K3-six">
<rect key="frame" x="0.0" y="0.0" width="600" height="695"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="708"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="sectionIndexBackgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
@@ -66,11 +66,13 @@
<constraints>
<constraint firstAttribute="width" constant="88" id="79O-5u-rWy"/>
<constraint firstItem="uWG-zH-Vjo" firstAttribute="centerY" secondItem="UhV-pr-kw4" secondAttribute="centerY" constant="-35" id="BKr-4U-Xpn"/>
<constraint firstItem="9ka-ho-kkM" firstAttribute="leading" secondItem="UhV-pr-kw4" secondAttribute="leading" constant="18" id="Cay-aa-P2d"/>
<constraint firstItem="9ka-ho-kkM" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="UhV-pr-kw4" secondAttribute="leading" id="Cay-aa-P2d"/>
<constraint firstItem="uWG-zH-Vjo" firstAttribute="centerX" secondItem="UhV-pr-kw4" secondAttribute="centerX" constant="-4" id="JBk-n5-unF"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="FQM-r1-a67" secondAttribute="trailing" constant="20" symbolic="YES" id="YfX-oc-QrI"/>
<constraint firstAttribute="bottom" secondItem="9ka-ho-kkM" secondAttribute="bottom" constant="28" id="bej-dB-MVA"/>
<constraint firstItem="FQM-r1-a67" firstAttribute="leading" secondItem="UhV-pr-kw4" secondAttribute="leading" constant="18" id="c48-WJ-cDt"/>
<constraint firstAttribute="bottom" secondItem="FQM-r1-a67" secondAttribute="bottom" constant="50" id="ccu-aB-Y5n"/>
<constraint firstAttribute="trailing" secondItem="9ka-ho-kkM" secondAttribute="trailing" constant="14" id="yC5-K2-pLt"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="dots" translatesAutoresizingMaskIntoConstraints="NO" id="lOX-iD-3OO">
@@ -88,13 +90,13 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="W 85th St, New York, 10024 " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="7" translatesAutoresizingMaskIntoConstraints="NO" id="BUL-Of-nxF" userLabel="W 85th St, New York, 10024">
<rect key="frame" x="124" y="28" width="426" height="16.5"/>
<rect key="frame" x="370" y="28" width="180" height="16.5"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="14"/>
<color key="textColor" red="0.20000000000000001" green="0.23921568627450979" blue="0.2627450980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="E 30th St, New York, 10016" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="7" translatesAutoresizingMaskIntoConstraints="NO" id="mNy-cH-kEi" userLabel="W 85th St, New York, 10024">
<rect key="frame" x="124" y="57" width="426" height="16.5"/>
<rect key="frame" x="378" y="57" width="172" height="16.5"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="14"/>
<color key="textColor" red="0.20000000000000001" green="0.23921568630000001" blue="0.26274509800000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
@@ -119,7 +121,9 @@
<constraints>
<constraint firstItem="fZc-Gv-4xg" firstAttribute="leading" secondItem="LnD-j0-rqc" secondAttribute="leading" id="L6e-Uv-9vS"/>
<constraint firstAttribute="bottom" secondItem="fZc-Gv-4xg" secondAttribute="bottom" id="ZRs-x2-A0s"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="fZc-Gv-4xg" secondAttribute="trailing" constant="20" symbolic="YES" id="jo5-im-pgZ"/>
<constraint firstItem="dKi-6r-6NP" firstAttribute="leading" secondItem="LnD-j0-rqc" secondAttribute="leading" id="oWr-Zs-xYW"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="dKi-6r-6NP" secondAttribute="trailing" constant="20" symbolic="YES" id="rtR-Zg-NTk"/>
<constraint firstItem="dKi-6r-6NP" firstAttribute="top" secondItem="LnD-j0-rqc" secondAttribute="top" id="wF5-DY-L1I"/>
</constraints>
</view>
@@ -143,8 +147,10 @@
<constraints>
<constraint firstItem="O5e-nR-iJW" firstAttribute="leading" secondItem="edX-4x-TiO" secondAttribute="leading" id="AYj-MP-1rV"/>
<constraint firstItem="O5e-nR-iJW" firstAttribute="top" secondItem="edX-4x-TiO" secondAttribute="top" id="cgQ-TI-IsS"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="a0P-Eh-vI9" secondAttribute="trailing" constant="20" symbolic="YES" id="ltE-8P-eIm"/>
<constraint firstItem="a0P-Eh-vI9" firstAttribute="leading" secondItem="edX-4x-TiO" secondAttribute="leading" id="oTf-nY-JXI"/>
<constraint firstAttribute="bottom" secondItem="a0P-Eh-vI9" secondAttribute="bottom" id="oeJ-q1-9t1"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="O5e-nR-iJW" secondAttribute="trailing" constant="20" symbolic="YES" id="uwS-Um-Dzp"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XAj-wA-vfn" userLabel="LeftVoew">
@@ -169,6 +175,8 @@
<constraint firstAttribute="bottom" secondItem="sA6-bX-nDC" secondAttribute="bottom" id="FLY-M3-HBk"/>
<constraint firstAttribute="height" constant="40" id="JEm-kR-Yum"/>
<constraint firstItem="X8Y-jq-qbv" firstAttribute="leading" secondItem="XAj-wA-vfn" secondAttribute="leading" id="bpa-pP-9bM"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="X8Y-jq-qbv" secondAttribute="trailing" constant="20" symbolic="YES" id="gFa-fO-TAV"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="sA6-bX-nDC" secondAttribute="trailing" constant="20" symbolic="YES" id="pCm-UL-opC"/>
<constraint firstItem="X8Y-jq-qbv" firstAttribute="top" secondItem="XAj-wA-vfn" secondAttribute="top" id="qjl-VM-Pwi"/>
</constraints>
</view>
@@ -177,7 +185,7 @@
<constraints>
<constraint firstItem="LnD-j0-rqc" firstAttribute="centerY" secondItem="XAj-wA-vfn" secondAttribute="centerY" id="1WA-KY-kPA"/>
<constraint firstAttribute="trailing" secondItem="LnD-j0-rqc" secondAttribute="trailing" id="23p-a2-A6L"/>
<constraint firstItem="BUL-Of-nxF" firstAttribute="leading" secondItem="CQr-i9-7br" secondAttribute="leading" constant="124" id="4Aj-wM-xak"/>
<constraint firstItem="BUL-Of-nxF" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="CQr-i9-7br" secondAttribute="leading" id="4Aj-wM-xak"/>
<constraint firstItem="XAj-wA-vfn" firstAttribute="width" secondItem="edX-4x-TiO" secondAttribute="width" id="4SA-da-3ek"/>
<constraint firstItem="lOX-iD-3OO" firstAttribute="top" secondItem="CQr-i9-7br" secondAttribute="top" constant="32" id="Dgd-LY-uFx"/>
<constraint firstItem="UhV-pr-kw4" firstAttribute="leading" secondItem="CQr-i9-7br" secondAttribute="leading" id="HeC-4J-km5"/>
@@ -186,7 +194,7 @@
<constraint firstAttribute="trailing" secondItem="mNy-cH-kEi" secondAttribute="trailing" constant="10" id="Rqh-At-NpG"/>
<constraint firstItem="XAj-wA-vfn" firstAttribute="leading" secondItem="UhV-pr-kw4" secondAttribute="trailing" constant="20" id="TBj-Xh-aIR"/>
<constraint firstItem="UhV-pr-kw4" firstAttribute="top" secondItem="CQr-i9-7br" secondAttribute="top" id="V89-lD-fHB"/>
<constraint firstItem="mNy-cH-kEi" firstAttribute="leading" secondItem="CQr-i9-7br" secondAttribute="leading" constant="124" id="XMf-Cs-Nu8"/>
<constraint firstItem="mNy-cH-kEi" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="CQr-i9-7br" secondAttribute="leading" id="XMf-Cs-Nu8"/>
<constraint firstItem="EVE-fe-u5I" firstAttribute="top" secondItem="CQr-i9-7br" secondAttribute="top" constant="52" id="Z3h-Dn-3CO"/>
<constraint firstItem="LnD-j0-rqc" firstAttribute="height" secondItem="XAj-wA-vfn" secondAttribute="height" id="anH-lP-Xab"/>
<constraint firstAttribute="height" constant="165" id="bfl-Uq-i0I"/>
@@ -237,6 +245,7 @@
<constraint firstAttribute="height" constant="49" id="AC3-t0-KIM"/>
<constraint firstAttribute="trailing" secondItem="4ve-4H-KPK" secondAttribute="trailing" constant="12" id="BgX-bA-WJy"/>
<constraint firstItem="4ve-4H-KPK" firstAttribute="top" secondItem="o36-zd-BZb" secondAttribute="top" id="RwT-Kf-gV5"/>
<constraint firstItem="4ve-4H-KPK" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="o36-zd-BZb" secondAttribute="leading" constant="20" symbolic="YES" id="bcC-Jw-xQO"/>
<constraint firstItem="vW5-Q1-KFs" firstAttribute="leading" secondItem="o36-zd-BZb" secondAttribute="leading" constant="14" id="eOn-QU-u2B"/>
<constraint firstAttribute="bottom" secondItem="4ve-4H-KPK" secondAttribute="bottom" id="n0y-uI-DZL"/>
<constraint firstAttribute="trailing" secondItem="7eb-NE-XLS" secondAttribute="trailing" id="ncs-Bz-WO7"/>
@@ -270,7 +279,9 @@
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="qOA-jB-5OO" secondAttribute="trailing" constant="20" symbolic="YES" id="3fn-95-aAz"/>
<constraint firstItem="qOA-jB-5OO" firstAttribute="top" secondItem="sdL-VL-QmS" secondAttribute="top" id="cGd-ZP-J1s"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="S4b-sI-0J6" secondAttribute="trailing" constant="20" symbolic="YES" id="hFA-F9-nvT"/>
<constraint firstItem="S4b-sI-0J6" firstAttribute="leading" secondItem="sdL-VL-QmS" secondAttribute="leading" id="j7G-um-lhR"/>
<constraint firstItem="qOA-jB-5OO" firstAttribute="leading" secondItem="sdL-VL-QmS" secondAttribute="leading" id="kbc-V1-6VS"/>
<constraint firstAttribute="height" constant="40" id="nCu-JM-dqc"/>
@@ -320,8 +331,10 @@
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="R9w-bP-fWa" secondAttribute="trailing" id="03y-gy-i1D"/>
<constraint firstItem="8pV-vb-qIN" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="LnF-7u-0Wm" secondAttribute="leading" constant="20" symbolic="YES" id="5v9-wv-MiA"/>
<constraint firstAttribute="trailing" secondItem="8pV-vb-qIN" secondAttribute="trailing" id="C3p-9o-b86"/>
<constraint firstItem="8pV-vb-qIN" firstAttribute="top" secondItem="LnF-7u-0Wm" secondAttribute="top" id="P9u-kS-VVp"/>
<constraint firstItem="R9w-bP-fWa" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="LnF-7u-0Wm" secondAttribute="leading" constant="20" symbolic="YES" id="Y6C-17-VcW"/>
<constraint firstAttribute="bottom" secondItem="R9w-bP-fWa" secondAttribute="bottom" id="g99-zI-5d7"/>
</constraints>
</view>
@@ -489,6 +502,7 @@
<constraint firstItem="h39-gf-gsn" firstAttribute="leading" secondItem="lbp-KK-0lW" secondAttribute="trailing" constant="1" id="pXq-um-J27"/>
<constraint firstAttribute="trailing" secondItem="dff-zA-mGx" secondAttribute="trailing" id="rP4-SC-s3a"/>
<constraint firstAttribute="trailing" secondItem="fuy-ww-tkB" secondAttribute="trailing" constant="22" id="trm-Sb-BDX"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="W63-7b-X8w" secondAttribute="trailing" constant="20" symbolic="YES" id="u1C-hG-9rE"/>
<constraint firstAttribute="height" constant="165" id="zna-xw-SZ3"/>
</constraints>
</view>
@@ -680,7 +694,7 @@
</connections>
</tableView>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="600" height="695"/>
<size key="freeformSize" width="600" height="708"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="WxO-6i-Q9B" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
@@ -26,9 +26,12 @@ import UIKit
class MainTableViewController: UITableViewController {
let kCloseCellHeight: CGFloat = 179
let kOpenCellHeight: CGFloat = 488
let kRowsCount = 10
enum Const {
static let closeCellHeight: CGFloat = 179
static let openCellHeight: CGFloat = 488
static let rowsCount = 10
}
var cellHeights: [CGFloat] = []
override func viewDidLoad() {
@@ -37,10 +40,24 @@ class MainTableViewController: UITableViewController {
}
private func setup() {
cellHeights = Array(repeating: kCloseCellHeight, count: kRowsCount)
tableView.estimatedRowHeight = kCloseCellHeight
tableView.rowHeight = UITableViewAutomaticDimension
cellHeights = Array(repeating: Const.closeCellHeight, count: Const.rowsCount)
tableView.estimatedRowHeight = Const.closeCellHeight
tableView.rowHeight = UITableView.automaticDimension
tableView.backgroundColor = UIColor(patternImage: #imageLiteral(resourceName: "background"))
if #available(iOS 10.0, *) {
tableView.refreshControl = UIRefreshControl()
tableView.refreshControl?.addTarget(self, action: #selector(refreshHandler), for: .valueChanged)
}
}
@objc func refreshHandler() {
let deadlineTime = DispatchTime.now() + .seconds(1)
DispatchQueue.main.asyncAfter(deadline: deadlineTime, execute: { [weak self] in
if #available(iOS 10.0, *) {
self?.tableView.refreshControl?.endRefreshing()
}
self?.tableView.reloadData()
})
}
}
@@ -59,7 +76,7 @@ extension MainTableViewController {
cell.backgroundColor = .clear
if cellHeights[indexPath.row] == kCloseCellHeight {
if cellHeights[indexPath.row] == Const.closeCellHeight {
cell.unfold(false, animated: false, completion: nil)
} else {
cell.unfold(true, animated: false, completion: nil)
@@ -89,13 +106,13 @@ extension MainTableViewController {
}
var duration = 0.0
let cellIsCollapsed = cellHeights[indexPath.row] == kCloseCellHeight
let cellIsCollapsed = cellHeights[indexPath.row] == Const.closeCellHeight
if cellIsCollapsed {
cellHeights[indexPath.row] = kOpenCellHeight
cellHeights[indexPath.row] = Const.openCellHeight
cell.unfold(true, animated: true, completion: nil)
duration = 0.5
} else {
cellHeights[indexPath.row] = kCloseCellHeight
cellHeights[indexPath.row] = Const.closeCellHeight
cell.unfold(false, animated: true, completion: nil)
duration = 0.8
}
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="0cn-rv-Emg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="0cn-rv-Emg">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
@@ -22,7 +23,7 @@
<!--Item-->
<scene sceneID="Q2d-BE-geS">
<objects>
<tableViewController storyboardIdentifier="TableViewController" id="0cn-rv-Emg" customClass="TableViewController" sceneMemberID="viewController">
<tableViewController storyboardIdentifier="TableViewController" id="0cn-rv-Emg" customClass="MainTableViewController" customModule="FoldingCell_Demo" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="667" sectionHeaderHeight="28" sectionFooterHeight="28" id="MwZ-K3-six">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -59,9 +59,12 @@
NSNumber *height = [self.cellHeights objectAtIndex:indexPath.row];
bool cellIsCollapsed = height.floatValue == self.kCloseCellHeight;
if (cellIsCollapsed) {
[(FoldingCell *) cell selectedAnimation:false animated:false completion: nil];
[(FoldingCell *)cell unfold:NO animated:NO completion:nil];
//[(FoldingCell *) cell selectedAnimation:false animated:false completion: nil];
} else {
[(FoldingCell *) cell selectedAnimation:true animated:false completion: nil];
[(FoldingCell *)cell unfold:YES animated:NO completion:nil];
//[(FoldingCell *) cell selectedAnimation:true animated:false completion: nil];
}
UIView *backgroundTopView = [cell viewWithTag:11];
@@ -108,11 +111,13 @@
bool cellIsCollapsed = height.floatValue == self.kCloseCellHeight;
if (cellIsCollapsed) {
[self.cellHeights setObject:[NSNumber numberWithFloat:self.kOpenCellHeight] atIndexedSubscript:indexPath.row];
[cell selectedAnimation:true animated:true completion: nil];
//[cell selectedAnimation:true animated:true completion: nil];
[cell unfold:YES animated:YES completion:nil];
duration = 0.5;
} else {
[self.cellHeights setObject:[NSNumber numberWithFloat:self.kCloseCellHeight] atIndexedSubscript:indexPath.row];
[cell selectedAnimation:false animated:true completion: nil];
//[cell selectedAnimation:false animated:true completion: nil];
[cell unfold:NO animated:YES completion:nil];
duration = 0.8;
}
+160 -28
View File
@@ -7,8 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
39669A04200CFDB30017D64F /* FoldingCell.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8499D8851D0054A8004B5B37 /* FoldingCell.framework */; };
39669A05200CFDB30017D64F /* FoldingCell.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8499D8851D0054A8004B5B37 /* FoldingCell.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5A0E1C3021414940006A0374 /* FoldingCellDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A0E1C2F21414940006A0374 /* FoldingCellDemoTests.swift */; };
8499D8881D0054A8004B5B37 /* FoldingCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 8499D8871D0054A8004B5B37 /* FoldingCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
9D57F31F1EDC7A6F0004599F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D57F31E1EDC7A6F0004599F /* AppDelegate.swift */; };
9D57F3241EDC7A6F0004599F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D57F3221EDC7A6F0004599F /* Main.storyboard */; };
@@ -17,6 +16,8 @@
9D57F32F1EDC7A850004599F /* MainTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D57F32E1EDC7A850004599F /* MainTableViewController.swift */; };
9D57F3311EDC7AAD0004599F /* DemoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D57F3301EDC7AAD0004599F /* DemoCell.swift */; };
9D57F3331EDC7ACF0004599F /* FoldingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D57F3321EDC7ACF0004599F /* FoldingCell.swift */; };
9D57F3341EDC7AD80004599F /* FoldingCell.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8499D8851D0054A8004B5B37 /* FoldingCell.framework */; };
9D57F3351EDC7AD80004599F /* FoldingCell.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8499D8851D0054A8004B5B37 /* FoldingCell.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9DAA51581EDDBAD700DFC539 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DAA51571EDDBAD700DFC539 /* main.m */; };
9DAA515B1EDDBAD700DFC539 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DAA515A1EDDBAD700DFC539 /* AppDelegate.m */; };
9DAA51611EDDBAD700DFC539 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DAA515F1EDDBAD700DFC539 /* Main.storyboard */; };
@@ -28,7 +29,14 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
39669A06200CFDB30017D64F /* PBXContainerItemProxy */ = {
5A0E1C3221414940006A0374 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 847A57FC1C294F750028FB84 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 9D57F31B1EDC7A6F0004599F;
remoteInfo = "FoldingCell-Demo";
};
9D57F3361EDC7AD80004599F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 847A57FC1C294F750028FB84 /* Project object */;
proxyType = 1;
@@ -45,13 +53,13 @@
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
39669A08200CFDB30017D64F /* Embed Frameworks */ = {
9D57F3381EDC7AD80004599F /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
39669A05200CFDB30017D64F /* FoldingCell.framework in Embed Frameworks */,
9D57F3351EDC7AD80004599F /* FoldingCell.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -70,6 +78,9 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
5A0E1C2D21414940006A0374 /* FoldingCellDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FoldingCellDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5A0E1C2F21414940006A0374 /* FoldingCellDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoldingCellDemoTests.swift; sourceTree = "<group>"; };
5A0E1C3121414940006A0374 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8499D8851D0054A8004B5B37 /* FoldingCell.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FoldingCell.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8499D8871D0054A8004B5B37 /* FoldingCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FoldingCell.h; sourceTree = "<group>"; };
8499D8891D0054A8004B5B37 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -95,6 +106,13 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
5A0E1C2A21414940006A0374 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8499D8811D0054A8004B5B37 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -106,7 +124,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
39669A04200CFDB30017D64F /* FoldingCell.framework in Frameworks */,
9D57F3341EDC7AD80004599F /* FoldingCell.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -121,12 +139,22 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
5A0E1C2E21414940006A0374 /* FoldingCellDemoTests */ = {
isa = PBXGroup;
children = (
5A0E1C2F21414940006A0374 /* FoldingCellDemoTests.swift */,
5A0E1C3121414940006A0374 /* Info.plist */,
);
path = FoldingCellDemoTests;
sourceTree = "<group>";
};
847A57FB1C294F750028FB84 = {
isa = PBXGroup;
children = (
8499D8861D0054A8004B5B37 /* FoldingCell */,
9D57F31D1EDC7A6F0004599F /* FoldingCell-Demo */,
9DAA51551EDDBAD700DFC539 /* FoldingCell-DemoObjc */,
5A0E1C2E21414940006A0374 /* FoldingCellDemoTests */,
847A58051C294F750028FB84 /* Products */,
);
sourceTree = "<group>";
@@ -137,6 +165,7 @@
8499D8851D0054A8004B5B37 /* FoldingCell.framework */,
9D57F31C1EDC7A6F0004599F /* FoldingCell-Demo.app */,
9DAA51541EDDBAD700DFC539 /* FoldingCell-DemoObjc.app */,
5A0E1C2D21414940006A0374 /* FoldingCellDemoTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -203,6 +232,24 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
5A0E1C2C21414940006A0374 /* FoldingCellDemoTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5A0E1C3421414940006A0374 /* Build configuration list for PBXNativeTarget "FoldingCellDemoTests" */;
buildPhases = (
5A0E1C2921414940006A0374 /* Sources */,
5A0E1C2A21414940006A0374 /* Frameworks */,
5A0E1C2B21414940006A0374 /* Resources */,
);
buildRules = (
);
dependencies = (
5A0E1C3321414940006A0374 /* PBXTargetDependency */,
);
name = FoldingCellDemoTests;
productName = FoldingCellDemoTests;
productReference = 5A0E1C2D21414940006A0374 /* FoldingCellDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
8499D8841D0054A8004B5B37 /* FoldingCell */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8499D88E1D0054A8004B5B37 /* Build configuration list for PBXNativeTarget "FoldingCell" */;
@@ -228,12 +275,12 @@
9D57F3181EDC7A6F0004599F /* Sources */,
9D57F3191EDC7A6F0004599F /* Frameworks */,
9D57F31A1EDC7A6F0004599F /* Resources */,
39669A08200CFDB30017D64F /* Embed Frameworks */,
9D57F3381EDC7AD80004599F /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
39669A07200CFDB30017D64F /* PBXTargetDependency */,
9D57F3371EDC7AD80004599F /* PBXTargetDependency */,
);
name = "FoldingCell-Demo";
productName = "FoldingCell-Demo";
@@ -265,19 +312,25 @@
847A57FC1C294F750028FB84 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0920;
LastSwiftUpdateCheck = 0940;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Alex K.";
TargetAttributes = {
5A0E1C2C21414940006A0374 = {
CreatedOnToolsVersion = 9.4;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
TestTargetID = 9D57F31B1EDC7A6F0004599F;
};
8499D8841D0054A8004B5B37 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 2VFCBFYPFW;
LastSwiftMigration = 0830;
DevelopmentTeam = LEAZS7L33U;
LastSwiftMigration = 1000;
};
9D57F31B1EDC7A6F0004599F = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 2VFCBFYPFW;
LastSwiftMigration = 0920;
DevelopmentTeam = 34MUF9YXTA;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
9DAA51531EDDBAD700DFC539 = {
@@ -303,11 +356,19 @@
8499D8841D0054A8004B5B37 /* FoldingCell */,
9D57F31B1EDC7A6F0004599F /* FoldingCell-Demo */,
9DAA51531EDDBAD700DFC539 /* FoldingCell-DemoObjc */,
5A0E1C2C21414940006A0374 /* FoldingCellDemoTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
5A0E1C2B21414940006A0374 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8499D8831D0054A8004B5B37 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -338,6 +399,14 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
5A0E1C2921414940006A0374 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5A0E1C3021414940006A0374 /* FoldingCellDemoTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8499D8801D0054A8004B5B37 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -369,10 +438,15 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
39669A07200CFDB30017D64F /* PBXTargetDependency */ = {
5A0E1C3321414940006A0374 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 9D57F31B1EDC7A6F0004599F /* FoldingCell-Demo */;
targetProxy = 5A0E1C3221414940006A0374 /* PBXContainerItemProxy */;
};
9D57F3371EDC7AD80004599F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 8499D8841D0054A8004B5B37 /* FoldingCell */;
targetProxy = 39669A06200CFDB30017D64F /* PBXContainerItemProxy */;
targetProxy = 9D57F3361EDC7AD80004599F /* PBXContainerItemProxy */;
};
9DAA51721EDDBB4800DFC539 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
@@ -417,6 +491,53 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
5A0E1C3521414940006A0374 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = FoldingCellDemoTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoldingCell-Demo.app/FoldingCell-Demo";
};
name = Debug;
};
5A0E1C3621414940006A0374 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = FoldingCellDemoTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoldingCell-Demo.app/FoldingCell-Demo";
};
name = Release;
};
847A58141C294F750028FB84 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -429,12 +550,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -461,7 +584,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -481,12 +604,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -507,7 +632,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -524,7 +649,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 2VFCBFYPFW;
DEVELOPMENT_TEAM = LEAZS7L33U;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -536,7 +661,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -552,7 +677,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 2VFCBFYPFW;
DEVELOPMENT_TEAM = LEAZS7L33U;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -563,7 +688,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCell;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -580,7 +705,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 2VFCBFYPFW;
DEVELOPMENT_TEAM = 34MUF9YXTA;
INFOPLIST_FILE = "FoldingCell-Demo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -588,8 +713,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -603,15 +727,14 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 2VFCBFYPFW;
DEVELOPMENT_TEAM = 34MUF9YXTA;
INFOPLIST_FILE = "FoldingCell-Demo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "ramotion.com.FoldingCell-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -658,6 +781,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
5A0E1C3421414940006A0374 /* Build configuration list for PBXNativeTarget "FoldingCellDemoTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5A0E1C3521414940006A0374 /* Debug */,
5A0E1C3621414940006A0374 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
847A57FF1C294F750028FB84 /* Build configuration list for PBXProject "FoldingCell" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
+162 -168
View File
@@ -25,136 +25,129 @@ import UIKit
/// UITableViewCell with folding animation
open class FoldingCell: UITableViewCell {
/// UIView whitch display when cell open
/// UIView is displayed when cell open
@IBOutlet open var containerView: UIView!
@IBOutlet open var containerViewTop: NSLayoutConstraint!
/// UIView whitch display when cell close
@IBOutlet open var foregroundView: RotatedView!
@IBOutlet open var foregroundViewTop: NSLayoutConstraint!
var animationView: UIView?
/// the number of folding elements. Default 2
@IBInspectable open var itemCount: NSInteger = 2
/// The color of the back cell
@IBInspectable open var backViewColor: UIColor = UIColor.brown
var animationItemViews: [RotatedView]?
/**
Folding animation types
- Open: Open direction
- Close: Close direction
*/
public enum AnimationType {
@objc public enum AnimationType : Int {
case open
case close
}
// MARK: life cicle
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
// MARK: Life Cycle
open override func awakeFromNib() {
super.awakeFromNib()
commonInit()
}
/**
Call this method in methods init(style: UITableViewCellStyle, reuseIdentifier: String?) after creating Views
*/
open func commonInit() {
@objc open func commonInit() {
configureDefaultState()
selectionStyle = .none
containerView.layer.cornerRadius = foregroundView.layer.cornerRadius
containerView.layer.masksToBounds = true
}
// MARK: configure
func configureDefaultState() {
guard let foregroundViewTop = self.foregroundViewTop,
let containerViewTop = self.containerViewTop else {
fatalError("set constratins outlets")
fatalError("set foregroundViewTop or containerViewTop outlets in storyboard")
}
containerViewTop.constant = foregroundViewTop.constant
containerView.alpha = 0
if let height = (foregroundView.constraints.filter { $0.firstAttribute == .height && $0.secondItem == nil }).first?.constant {
foregroundView.layer.anchorPoint = CGPoint(x: 0.5, y: 1)
foregroundViewTop.constant += height / 2
}
foregroundView.layer.transform = foregroundView.transform3d()
createAnimationView()
contentView.bringSubview(toFront: foregroundView)
contentView.bringSubviewToFront(foregroundView)
}
func createAnimationItemView() -> [RotatedView] {
guard let animationView = self.animationView else {
fatalError()
}
var items = [RotatedView]()
items.append(foregroundView)
var rotatedViews = [RotatedView]()
for case let itemView as RotatedView in animationView.subviews.filter({ $0 is RotatedView }).sorted(by: { $0.tag < $1.tag }) {
rotatedViews.append(itemView)
if let backView = itemView.backView {
rotatedViews.append(backView)
}
animationView?.subviews
.lazy
.compactMap({ $0 as? RotatedView })
.sorted(by: { $0.tag < $1.tag })
.forEach { itemView in
rotatedViews.append(itemView)
if let backView = itemView.backView {
rotatedViews.append(backView)
}
}
items.append(contentsOf: rotatedViews)
return items
}
func configureAnimationItems(_ animationType: AnimationType) {
guard let animationViewSuperView = animationView?.subviews else {
fatalError()
}
if animationType == .open {
for view in animationViewSuperView.filter({ $0 is RotatedView }) {
view.alpha = 0
}
animationView?.subviews
.compactMap { $0 as? RotatedView }
.forEach { $0.alpha = 0 }
} else {
for case let view as RotatedView in animationViewSuperView.filter({ $0 is RotatedView }) {
if animationType == .open {
view.alpha = 0
} else {
view.alpha = 1
view.backView?.alpha = 0
}
animationView?.subviews
.compactMap { $0 as? RotatedView }
.forEach {
if animationType == .open {
$0.alpha = 0
} else {
$0.alpha = 1
$0.backView?.alpha = 0
}
}
}
}
func createAnimationView() {
animationView = UIView(frame: containerView.frame)
animationView?.layer.cornerRadius = foregroundView.layer.cornerRadius
animationView?.backgroundColor = .clear
animationView?.translatesAutoresizingMaskIntoConstraints = false
animationView?.alpha = 0
guard let animationView = self.animationView else { return }
self.contentView.addSubview(animationView)
// copy constraints from containerView
var newConstraints = [NSLayoutConstraint]()
for constraint in self.contentView.constraints {
@@ -162,57 +155,57 @@ open class FoldingCell: UITableViewCell {
let newConstraint = NSLayoutConstraint(item: animationView, attribute: constraint.firstAttribute,
relatedBy: constraint.relation, toItem: constraint.secondItem, attribute: constraint.secondAttribute,
multiplier: constraint.multiplier, constant: constraint.constant)
newConstraints.append(newConstraint)
} else if let firstItem = constraint.firstItem as? UIView, let secondItem: UIView = constraint.secondItem as? UIView, secondItem == containerView {
let newConstraint = NSLayoutConstraint(item: firstItem, attribute: constraint.firstAttribute,
relatedBy: constraint.relation, toItem: animationView, attribute: constraint.secondAttribute,
multiplier: constraint.multiplier, constant: constraint.constant)
newConstraints.append(newConstraint)
}
}
self.contentView.addConstraints(newConstraints)
for constraint in containerView.constraints { // added height constraint
if constraint.firstAttribute == .height, let item: UIView = constraint.firstItem as? UIView, item == containerView {
let newConstraint = NSLayoutConstraint(item: animationView, attribute: constraint.firstAttribute,
relatedBy: constraint.relation, toItem: nil, attribute: constraint.secondAttribute,
multiplier: constraint.multiplier, constant: constraint.constant)
animationView.addConstraint(newConstraint)
}
}
}
func addImageItemsToAnimationView() {
containerView.alpha = 1
let containerViewSize = containerView.bounds.size
let foregroundViewSize = foregroundView.bounds.size
// added first item
var image = containerView.pb_takeSnapshot(CGRect(x: 0, y: 0, width: containerViewSize.width, height: foregroundViewSize.height))
var image = containerView.takeSnapshot(CGRect(x: 0, y: 0, width: containerViewSize.width, height: foregroundViewSize.height))
var imageView = UIImageView(image: image)
imageView.tag = 0
imageView.layer.cornerRadius = foregroundView.layer.cornerRadius
animationView?.addSubview(imageView)
// added secod item
image = containerView.pb_takeSnapshot(CGRect(x: 0, y: foregroundViewSize.height, width: containerViewSize.width, height: foregroundViewSize.height))
image = containerView.takeSnapshot(CGRect(x: 0, y: foregroundViewSize.height, width: containerViewSize.width, height: foregroundViewSize.height))
imageView = UIImageView(image: image)
let rotatedView = RotatedView(frame: imageView.frame)
rotatedView.tag = 1
rotatedView.layer.anchorPoint = CGPoint(x: 0.5, y: 0)
rotatedView.layer.transform = rotatedView.transform3d()
rotatedView.addSubview(imageView)
animationView?.addSubview(rotatedView)
rotatedView.frame = CGRect(x: imageView.frame.origin.x, y: foregroundViewSize.height, width: containerViewSize.width, height: foregroundViewSize.height)
// added other views
let itemHeight = (containerViewSize.height - 2 * foregroundViewSize.height) / CGFloat(itemCount - 2)
if itemCount == 2 {
// decrease containerView height or increase itemCount
assert(containerViewSize.height - 2 * foregroundViewSize.height == 0, "contanerView.height too high")
@@ -220,58 +213,58 @@ open class FoldingCell: UITableViewCell {
// decrease containerView height or increase itemCount
assert(containerViewSize.height - 2 * foregroundViewSize.height >= itemHeight, "contanerView.height too high")
}
var yPosition = 2 * foregroundViewSize.height
var tag = 2
for _ in 2 ..< itemCount {
image = containerView.pb_takeSnapshot(CGRect(x: 0, y: yPosition, width: containerViewSize.width, height: itemHeight))
image = containerView.takeSnapshot(CGRect(x: 0, y: yPosition, width: containerViewSize.width, height: itemHeight))
imageView = UIImageView(image: image)
let rotatedView = RotatedView(frame: imageView.frame)
rotatedView.addSubview(imageView)
rotatedView.layer.anchorPoint = CGPoint(x: 0.5, y: 0)
rotatedView.layer.transform = rotatedView.transform3d()
animationView?.addSubview(rotatedView)
rotatedView.frame = CGRect(x: 0, y: yPosition, width: rotatedView.bounds.size.width, height: itemHeight)
rotatedView.tag = tag
yPosition += itemHeight
tag += 1
}
containerView.alpha = 0
if let animationView = self.animationView {
// added back view
var previuosView: RotatedView?
for case let container as RotatedView in animationView.subviews.sorted(by: { $0.tag < $1.tag })
where container.tag > 0 && container.tag < animationView.subviews.count {
previuosView?.addBackView(container.bounds.size.height, color: backViewColor)
previuosView = container
previuosView?.addBackView(container.bounds.size.height, color: backViewColor)
previuosView = container
}
}
animationItemViews = createAnimationItemView()
}
fileprivate func removeImageItemsFromAnimationView() {
guard let animationView = self.animationView else {
return
}
animationView.subviews.forEach({ $0.removeFromSuperview() })
}
// MARK: public
/// Unfold cell.
///
/// - Parameters:
/// - value: unfold = true; collapse = false.
/// - animated: animate changes.
/// - completion: A block object to be executed when the animation sequence ends.
open func unfold(_ value: Bool, animated: Bool = true, completion: (() -> Void)? = nil) {
@objc open func unfold(_ value: Bool, animated: Bool = true, completion: (() -> Void)? = nil) {
if animated {
value ? openAnimation(completion) : closeAnimation(completion)
} else {
@@ -279,34 +272,22 @@ open class FoldingCell: UITableViewCell {
containerView.alpha = value ? 1 : 0
}
}
/**
Open or close cell
- parameter isSelected: Specify true if you want to open cell or false if you close cell.
- parameter animated: Specify true if you want to animate the change in visibility or false if you want immediately.
- parameter completion: A block object to be executed when the animation sequence ends.
*/
@available(iOS, deprecated, message: "Use unfold(_:animated:completion) method instead.")
open func selectedAnimation(_ isSelected: Bool, animated: Bool, completion: (() -> Void)?) {
unfold(isSelected, animated: animated, completion: completion)
}
open func isAnimating() -> Bool {
@objc open func isAnimating() -> Bool {
return animationView?.alpha == 1 ? true : false
}
open var isUnfolded = false
@objc open var isUnfolded = false
// MARK: Animations
open func animationDuration(_ itemIndex: NSInteger, type: AnimationType) -> TimeInterval {
@objc open func animationDuration(_ itemIndex: NSInteger, type: AnimationType) -> TimeInterval {
return type == .close ? durationsForCollapsedState[itemIndex] : durationsForExpandedState[itemIndex]
}
open var durationsForExpandedState: [TimeInterval] = []
open var durationsForCollapsedState: [TimeInterval] = []
@objc open var durationsForExpandedState: [TimeInterval] = []
@objc open var durationsForCollapsedState: [TimeInterval] = []
func durationSequence(_ type: AnimationType) -> [TimeInterval] {
var durations = [TimeInterval]()
for i in 0 ..< itemCount - 1 {
@@ -316,90 +297,86 @@ open class FoldingCell: UITableViewCell {
}
return durations
}
func openAnimation(_ completion: (() -> Void)?) {
public func openAnimation(_ completion: (() -> Void)?) {
isUnfolded = true
removeImageItemsFromAnimationView()
addImageItemsToAnimationView()
guard let animationView = self.animationView else {
return
}
animationView.alpha = 1
animationView?.alpha = 1
containerView.alpha = 0
let durations = durationSequence(.open)
var delay: TimeInterval = 0
var timing = kCAMediaTimingFunctionEaseIn
var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
var from: CGFloat = 0.0
var to: CGFloat = -CGFloat.pi / 2
var hidden = true
configureAnimationItems(.open)
guard let animationItemViews = self.animationItemViews else {
return
}
for index in 0 ..< animationItemViews.count {
let animatedView = animationItemViews[index]
animatedView.foldingAnimation(timing, from: from, to: to, duration: durations[index], delay: delay, hidden: hidden)
from = from == 0.0 ? CGFloat.pi / 2 : 0.0
to = to == 0.0 ? -CGFloat.pi / 2 : 0.0
timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn
timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
hidden = !hidden
delay += durations[index]
}
let firstItemView = animationView.subviews.filter { $0.tag == 0 }.first
let firstItemView = animationView?.subviews.filter { $0.tag == 0 }.first
firstItemView?.layer.masksToBounds = true
DispatchQueue.main.asyncAfter(deadline: .now() + durations[0], execute: {
firstItemView?.layer.cornerRadius = 0
})
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
self.animationView?.alpha = 0
self.containerView.alpha = 1
completion?()
}
}
func closeAnimation(_ completion: (() -> Void)?) {
public func closeAnimation(_ completion: (() -> Void)?) {
isUnfolded = false
removeImageItemsFromAnimationView()
addImageItemsToAnimationView()
guard let animationItemViews = self.animationItemViews else {
fatalError()
}
animationView?.alpha = 1
containerView.alpha = 0
var durations: [TimeInterval] = durationSequence(.close).reversed()
var delay: TimeInterval = 0
var timing = kCAMediaTimingFunctionEaseIn
var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
var from: CGFloat = 0.0
var to: CGFloat = CGFloat.pi / 2
var hidden = true
configureAnimationItems(.close)
if durations.count < animationItemViews.count {
fatalError("wrong override func animationDuration(itemIndex:NSInteger, type:AnimationType)-> NSTimeInterval")
}
for index in 0 ..< animationItemViews.count {
let animatedView = animationItemViews.reversed()[index]
animatedView.foldingAnimation(timing, from: from, to: to, duration: durations[index], delay: delay, hidden: hidden)
to = to == 0.0 ? CGFloat.pi / 2 : 0.0
from = from == 0.0 ? -CGFloat.pi / 2 : 0.0
timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn
timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
hidden = !hidden
delay += durations[index]
}
@@ -407,7 +384,7 @@ open class FoldingCell: UITableViewCell {
self.animationView?.alpha = 0
completion?()
})
let firstItemView = animationView?.subviews.filter { $0.tag == 0 }.first
firstItemView?.layer.cornerRadius = 0
firstItemView?.layer.masksToBounds = true
@@ -424,9 +401,15 @@ open class FoldingCell: UITableViewCell {
// MARK: RotatedView
open class RotatedView: UIView {
fileprivate enum Const {
static let rotationX = "rotation.x"
static let transformRotationX = "transform.rotation.x"
}
var hiddenAfterAnimation = false
var backView: RotatedView?
func addBackView(_ height: CGFloat, color: UIColor) {
let view = RotatedView(frame: CGRect.zero)
view.backgroundColor = color
@@ -435,10 +418,10 @@ open class RotatedView: UIView {
view.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(view)
backView = view
view.addConstraint(NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height,
multiplier: 1, constant: height))
self.addConstraints([
NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1,
constant: self.bounds.size.height - height + height / 2),
@@ -446,12 +429,12 @@ open class RotatedView: UIView {
multiplier: 1, constant: 0),
NSLayoutConstraint(item: view, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing,
multiplier: 1, constant: 0),
])
])
}
}
extension RotatedView: CAAnimationDelegate {
func rotatedX(_ angle: CGFloat) {
var allTransofrom = CATransform3DIdentity
let rotateTransform = CATransform3DMakeRotation(angle, 1, 0, 0)
@@ -459,37 +442,37 @@ extension RotatedView: CAAnimationDelegate {
allTransofrom = CATransform3DConcat(allTransofrom, transform3d())
self.layer.transform = allTransofrom
}
func transform3d() -> CATransform3D {
var transform = CATransform3DIdentity
transform.m34 = 2.5 / -2000
return transform
}
// MARK: animations
func foldingAnimation(_ timing: String, from: CGFloat, to: CGFloat, duration: TimeInterval, delay: TimeInterval, hidden: Bool) {
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.x")
rotateAnimation.timingFunction = CAMediaTimingFunction(name: timing)
let rotateAnimation = CABasicAnimation(keyPath: Const.transformRotationX)
rotateAnimation.timingFunction = CAMediaTimingFunction(name: convertToCAMediaTimingFunctionName(timing))
rotateAnimation.fromValue = from
rotateAnimation.toValue = to
rotateAnimation.duration = duration
rotateAnimation.delegate = self
rotateAnimation.fillMode = kCAFillModeForwards
rotateAnimation.fillMode = CAMediaTimingFillMode.forwards
rotateAnimation.isRemovedOnCompletion = false
rotateAnimation.beginTime = CACurrentMediaTime() + delay
self.hiddenAfterAnimation = hidden
self.layer.add(rotateAnimation, forKey: "rotation.x")
self.layer.add(rotateAnimation, forKey: Const.rotationX)
}
public func animationDidStart(_: CAAnimation) {
self.layer.shouldRasterize = true
self.alpha = 1
}
public func animationDidStop(_: CAAnimation, finished _: Bool) {
if hiddenAfterAnimation {
self.alpha = 0
@@ -500,18 +483,29 @@ extension RotatedView: CAAnimationDelegate {
}
}
// MARK: UIView + extension
private extension UIView {
func pb_takeSnapshot(_ frame: CGRect) -> UIImage? {
func takeSnapshot(_ frame: CGRect) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(frame.size, false, 0)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
context.translateBy(x: frame.origin.x * -1, y: frame.origin.y * -1)
layer.render(in: context)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromCAMediaTimingFunctionName(_ input: CAMediaTimingFunctionName) -> String {
return input.rawValue
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToCAMediaTimingFunctionName(_ input: String) -> CAMediaTimingFunctionName {
return CAMediaTimingFunctionName(rawValue: input)
}
@@ -0,0 +1,35 @@
//
// FoldingCellDemoTests.swift
// FoldingCellDemoTests
//
// Created by Alex K on 06/09/2018.
// Copyright © 2018 Alex K. All rights reserved.
//
import XCTest
import UIKit
@testable import FoldingCell
@testable import FoldingCell_Demo
class FoldingCellDemoTests: XCTestCase {
var foldingCell: FoldingCell!
override func setUp() {
super.setUp()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MainTableViewController") as! MainTableViewController
_ = vc.view
foldingCell = vc.tableView.dequeueReusableCell(withIdentifier: "FoldingCell", for: IndexPath(row: 0, section: 0)) as? FoldingCell
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testCreateFoldingCell() {
XCTAssertNotNil(foldingCell)
}
}
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
+20 -18
View File
@@ -1,33 +1,35 @@
![header](./header.png)
![Animation](./Screenshots/folding-cell.gif)
<img src="https://github.com/Ramotion/folding-cell/blob/master/Screenshots/foldingCell.gif" width="600" height="450" /></a>
<br><br/>
# FoldingCell
[![CocoaPods](https://img.shields.io/cocoapods/p/FoldingCell.svg)](https://cocoapods.org/pods/FoldingCell)
[![CocoaPods](https://img.shields.io/cocoapods/v/FoldingCell.svg)](http://cocoapods.org/pods/FoldingCell)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Ramotion/folding-cell)
[![Twitter](https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat)](http://twitter.com/Ramotion)
[![Travis](https://img.shields.io/travis/Ramotion/folding-cell.svg)](https://travis-ci.org/Ramotion/folding-cell)
[![codebeat badge](https://codebeat.co/badges/6f67da5d-c416-4bac-9fb7-c2dc938feedc)](https://codebeat.co/projects/github-com-ramotion-folding-cell)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift 4.0](https://img.shields.io/badge/Swift-4.0-green.svg?style=flat)](https://developer.apple.com/swift/)
[![Analytics](https://ga-beacon.appspot.com/UA-84973210-1/ramotion/folding-cell)](https://github.com/igrigorik/ga-beacon)
[![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/Ramotion)
# Check this library on other platforms:
<a href="https://github.com/Ramotion/folding-cell-android">
<a href="https://github.com/Ramotion/folding-cell-android">
<img src="https://github.com/ramotion/navigation-stack/raw/master/Android_Java@2x.png" width="178" height="81"></a>
**Looking for developers for your project?**<br>
This project is maintained by Ramotion, Inc. We specialize in the designing and coding of custom UI for Mobile Apps and Websites.
<a href="https://ramotion.com/?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell-contact-us/#Get_in_Touch">
<a href="mailto:alex.a@ramotion.com?subject=Project%20inquiry%20from%20Github">
<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a> <br>
The [iPhone mockup](https://store.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell) available [here](https://store.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell).
The [iPhone mockup](https://store.ramotion.com/product/iphone-x-clay-mockups?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell) available [here](https://store.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell).
## Requirements
- iOS 8.0+
- Xcode 7.3
- Xcode 9.0+
## Installation
@@ -72,7 +74,6 @@ Your result should be something like this picture:
![1.3](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.3.png)
[Demonstration adding constraints for foregroundView, containerView](https://vimeo.com/154954299)
4) Set ``` @IBInspectable var itemCount: NSInteger ``` property is a count of folding (it IBInspectable you can set in storyboard). range 2 or greater. Default value is 2
@@ -110,14 +111,14 @@ fileprivate struct C {
}
var duration = 0.0
if cellHeights[indexPath.row] == kCloseCellHeight { // open cell
cellHeights[indexPath.row] = kOpenCellHeight
cell.selectedAnimation(true, animated: true, completion: nil)
if cellIsCollapsed {
cellHeights[indexPath.row] = Const.openCellHeight
cell.unfold(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
} else {
cellHeights[indexPath.row] = Const.closeCellHeight
cell.unfold(false, animated: true, completion: nil)
duration = 0.8
}
UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseOut, animations: { _ in
@@ -160,7 +161,7 @@ Create foregroundView and containerView from code (steps 2 - 3) look example:
Folding cell is released under the MIT license.
See [LICENSE](./LICENSE) for details.
<br>
This library is a part of a <a href="https://github.com/Ramotion/swift-ui-animation-components-and-libraries"><b>selection of our best UI open-source projects.</b></a>
# Get the Showroom App for iOS to give it a try
Try this UI component and more like this in our iOS app. Contact us if interested.
@@ -168,10 +169,11 @@ Try this UI component and more like this in our iOS app. Contact us if intereste
<a href="https://itunes.apple.com/app/apple-store/id1182360240?pt=550053&ct=folding-cell&mt=8" >
<img src="https://github.com/ramotion/gliding-collection/raw/master/app_store@2x.png" width="117" height="34"></a>
<a href="https://ramotion.com/?utm_source=gthb&utm_medium=special&utm_campaign=folding-cell-contact-us/#Get_in_Touch">
<a href="mailto:alex.a@ramotion.com?subject=Project%20inquiry%20from%20Github">
<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a>
<br>
<br>
Follow us for the latest updates<br>[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/folding-cell)
[![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)
## Follow us for the latest update<br>
<a href="https://goo.gl/rPFpid" >
<img src="https://i.imgur.com/ziSqeSo.png/" width="156" height="28"></a>
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB