Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7922cda3b4 | ||
|
|
69624db27e | ||
|
|
e4f3ca0679 | ||
|
|
5f123c4959 | ||
|
|
a230b36692 | ||
|
|
53e9769d0f | ||
|
|
fdf5c80e3b | ||
|
|
205858f47a |
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FoldingCell'
|
||||
s.version = '0.1'
|
||||
s.version = '0.2'
|
||||
s.summary = 'UITableViewCell with folding animation.'
|
||||
s.homepage = 'https://github.com/Ramotion/folding-cell'
|
||||
s.license = 'MIT'
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
840B984C1C33FE660081B926 /* FoldingCellFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 840B984B1C33FE660081B926 /* FoldingCellFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
840B98501C33FE660081B926 /* FoldingCellFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 840B98491C33FE660081B926 /* FoldingCellFramework.framework */; };
|
||||
840B98511C33FE660081B926 /* FoldingCellFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 840B98491C33FE660081B926 /* FoldingCellFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
840B98561C33FE730081B926 /* FoldingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847A581A1C294FAB0028FB84 /* FoldingCell.swift */; };
|
||||
847A58081C294F750028FB84 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847A58071C294F750028FB84 /* AppDelegate.swift */; };
|
||||
847A580D1C294F750028FB84 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 847A580B1C294F750028FB84 /* Main.storyboard */; };
|
||||
847A580F1C294F750028FB84 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 847A580E1C294F750028FB84 /* Assets.xcassets */; };
|
||||
@@ -30,16 +26,6 @@
|
||||
84CDB15A1C2D416400FCD7C8 /* DemoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CDB1591C2D416400FCD7C8 /* DemoCell.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
840B984E1C33FE660081B926 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 847A57FC1C294F750028FB84 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 840B98481C33FE660081B926;
|
||||
remoteInfo = FoldingCellFramework;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
840B98551C33FE660081B926 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
@@ -47,7 +33,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
840B98511C33FE660081B926 /* FoldingCellFramework.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -55,7 +40,6 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
840B98491C33FE660081B926 /* FoldingCellFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FoldingCellFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
840B984B1C33FE660081B926 /* FoldingCellFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FoldingCellFramework.h; sourceTree = "<group>"; };
|
||||
840B984D1C33FE660081B926 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
847A58041C294F750028FB84 /* FoldingCell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FoldingCell.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -80,18 +64,10 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
840B98451C33FE660081B926 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
847A58011C294F750028FB84 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
840B98501C33FE660081B926 /* FoldingCellFramework.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -120,7 +96,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
847A58041C294F750028FB84 /* FoldingCell.app */,
|
||||
840B98491C33FE660081B926 /* FoldingCellFramework.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -168,36 +143,7 @@
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
840B98461C33FE660081B926 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
840B984C1C33FE660081B926 /* FoldingCellFramework.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
840B98481C33FE660081B926 /* FoldingCellFramework */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 840B98541C33FE660081B926 /* Build configuration list for PBXNativeTarget "FoldingCellFramework" */;
|
||||
buildPhases = (
|
||||
840B98441C33FE660081B926 /* Sources */,
|
||||
840B98451C33FE660081B926 /* Frameworks */,
|
||||
840B98461C33FE660081B926 /* Headers */,
|
||||
840B98471C33FE660081B926 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = FoldingCellFramework;
|
||||
productName = FoldingCellFramework;
|
||||
productReference = 840B98491C33FE660081B926 /* FoldingCellFramework.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
847A58031C294F750028FB84 /* FoldingCell */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 847A58161C294F750028FB84 /* Build configuration list for PBXNativeTarget "FoldingCell" */;
|
||||
@@ -210,7 +156,6 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
840B984F1C33FE660081B926 /* PBXTargetDependency */,
|
||||
);
|
||||
name = FoldingCell;
|
||||
productName = FoldingCell;
|
||||
@@ -227,9 +172,6 @@
|
||||
LastUpgradeCheck = 0720;
|
||||
ORGANIZATIONNAME = "Alex K.";
|
||||
TargetAttributes = {
|
||||
840B98481C33FE660081B926 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
};
|
||||
847A58031C294F750028FB84 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
};
|
||||
@@ -249,19 +191,11 @@
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
847A58031C294F750028FB84 /* FoldingCell */,
|
||||
840B98481C33FE660081B926 /* FoldingCellFramework */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
840B98471C33FE660081B926 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
847A58021C294F750028FB84 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -285,14 +219,6 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
840B98441C33FE660081B926 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
840B98561C33FE730081B926 /* FoldingCell.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
847A58001C294F750028FB84 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -306,14 +232,6 @@
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
840B984F1C33FE660081B926 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 840B98481C33FE660081B926 /* FoldingCellFramework */;
|
||||
targetProxy = 840B984E1C33FE660081B926 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
847A580B1C294F750028FB84 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
@@ -334,46 +252,6 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
840B98521C33FE660081B926 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = FoldingCellFramework/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellFramework;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
840B98531C33FE660081B926 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = FoldingCellFramework/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellFramework;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
847A58141C294F750028FB84 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -484,14 +362,6 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
840B98541C33FE660081B926 /* Build configuration list for PBXNativeTarget "FoldingCellFramework" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
840B98521C33FE660081B926 /* Debug */,
|
||||
840B98531C33FE660081B926 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
847A57FF1C294F750028FB84 /* Build configuration list for PBXProject "FoldingCell" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
||||
@@ -31,7 +31,7 @@ public class FoldingCell: UITableViewCell {
|
||||
@IBOutlet weak var foregroundView: RotatedView!
|
||||
var animationView: UIView?
|
||||
|
||||
@IBInspectable var itemCount: NSInteger = 2
|
||||
@IBInspectable var itemCount: NSInteger = 2 //count of folding
|
||||
|
||||
@IBInspectable var backViewColor: UIColor = UIColor.brownColor()
|
||||
|
||||
@@ -50,7 +50,6 @@ public class FoldingCell: UITableViewCell {
|
||||
configureDefaultState()
|
||||
|
||||
self.selectionStyle = .None
|
||||
containerView.backgroundColor = UIColor.clearColor()
|
||||
|
||||
containerView.layer.cornerRadius = foregroundView.layer.cornerRadius
|
||||
containerView.layer.masksToBounds = true
|
||||
|
||||
@@ -30,7 +30,7 @@ class MainTableViewController: UITableViewController {
|
||||
|
||||
let kRowsCount = 10
|
||||
|
||||
var cellHeights: [CGFloat]?
|
||||
var cellHeights = [CGFloat]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@@ -41,9 +41,8 @@ class MainTableViewController: UITableViewController {
|
||||
|
||||
// MARK: configure
|
||||
func createCellHeightsArray() {
|
||||
cellHeights = Array()
|
||||
for _ in 0...kRowsCount {
|
||||
cellHeights?.append(kCloseCellHeight)
|
||||
cellHeights.append(kCloseCellHeight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ class MainTableViewController: UITableViewController {
|
||||
let foldingCell = cell as! FoldingCell
|
||||
foldingCell.backgroundColor = UIColor.clearColor()
|
||||
|
||||
if cellHeights![indexPath.row] == kCloseCellHeight {
|
||||
if cellHeights[indexPath.row] == kCloseCellHeight {
|
||||
foldingCell.selectedAnimation(false, animated: false, completion:nil)
|
||||
} else {
|
||||
foldingCell.selectedAnimation(true, animated: false, completion: nil)
|
||||
@@ -74,7 +73,7 @@ class MainTableViewController: UITableViewController {
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
return cellHeights![indexPath.row]
|
||||
return cellHeights[indexPath.row]
|
||||
}
|
||||
|
||||
// MARK: Table vie delegate
|
||||
@@ -88,12 +87,12 @@ class MainTableViewController: UITableViewController {
|
||||
}
|
||||
|
||||
var duration = 0.0
|
||||
if cellHeights![indexPath.row] == kCloseCellHeight { // open cell
|
||||
cellHeights![indexPath.row] = kOpenCellHeight
|
||||
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
|
||||
cellHeights[indexPath.row] = kCloseCellHeight
|
||||
cell.selectedAnimation(false, animated: true, completion: nil)
|
||||
duration = 1.1
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ Just add the FoldingCell.swift file to your project.
|
||||
|
||||
or use [CocoaPods](https://cocoapods.org) with Podfile:
|
||||
``` ruby
|
||||
pod 'FoldingCell', '~> 0.1'
|
||||
pod 'FoldingCell', '~> 0.2'
|
||||
```
|
||||
|
||||
|
||||
@@ -43,36 +43,7 @@ property `containerView`. Add constraints from this view to the superview like i
|
||||
Your result should be something like this picture:
|
||||

|
||||
|
||||
4) Now lets add folding views
|
||||
|
||||
4.1) Add a UIView to `containerView` (where `ContainerView` is the UIView which you've added on step 3)
|
||||
Add constraints from this view to `containerView` as in the picture:
|
||||
|
||||

|
||||
|
||||
For correct animation, the height constraint constant should be equal to `foregroundView`'s height constraint constant.
|
||||
Result:
|
||||
|
||||

|
||||
|
||||
4.2) Add a `UIView` to `containerView` inheriting from `RotatedView`. Add constraints from
|
||||
this view to `containerView` as in the picture:
|
||||
|
||||
.
|
||||
|
||||
For correct animation, the height constraint constant must be equal to `foregroundView`'s height constraint constant.
|
||||
Add the identifier "yPosition" for the top constraint. **The tag must be equal to 1**
|
||||
Result:
|
||||
|
||||

|
||||
|
||||
The following steps are optional (you can add as many views as you want).
|
||||
|
||||
4.3) repeat 4.2, but **increasing the tag by one**. (For the correct animation, height of the view
|
||||
must be less than or equal to that of the previous view).
|
||||
|
||||
The height of `containerView` must be equal to the sum of the heights of its subviews:
|
||||

|
||||
4) Set ``` @IBInspectable var itemCount: NSInteger ``` property is a count of folding (it IBInspectable you can set in storyborad). range 2 or greater. Default value is 2
|
||||
|
||||
Ok, we've finished configuring the cell.
|
||||
|
||||
@@ -86,7 +57,7 @@ Ok, we've finished configuring the cell.
|
||||
5.2) Add property
|
||||
|
||||
``` swift
|
||||
var cellHeights: [CGFloat]?
|
||||
var cellHeights = [CGFloat]()
|
||||
```
|
||||
|
||||
create in viewDidLoad:
|
||||
@@ -95,7 +66,7 @@ Ok, we've finished configuring the cell.
|
||||
super.viewDidLoad()
|
||||
|
||||
for _ in 0...kRowsCount {
|
||||
cellHeights?.append(kCloseCellHeight)
|
||||
cellHeights.append(kCloseCellHeight)
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -103,7 +74,7 @@ Ok, we've finished configuring the cell.
|
||||
5.3) Override method:
|
||||
``` swift
|
||||
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
return cellHeights![indexPath.row]
|
||||
return cellHeights[indexPath.row]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -113,12 +84,12 @@ Ok, we've finished configuring the cell.
|
||||
let cell = tableView.cellForRowAtIndexPath(indexPath) as! FoldingCell
|
||||
|
||||
var duration = 0.0
|
||||
if cellHeights![indexPath.row] == kCloseCellHeight { // open cell
|
||||
cellHeights![indexPath.row] = kOpenCellHeight
|
||||
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
|
||||
cellHeights[indexPath.row] = kCloseCellHeight
|
||||
cell.selectedAnimation(false, animated: true, completion: nil)
|
||||
duration = 1.1
|
||||
}
|
||||
@@ -149,7 +120,7 @@ Ok, we've finished configuring the cell.
|
||||
``` swift
|
||||
override func animationDuration(itemIndex:NSInteger, type:AnimationType)-> NSTimeInterval {
|
||||
|
||||
// durations count equal containerView.subViews.count - 1
|
||||
// durations count equal it itemCount
|
||||
let durations = [0.33, 0.26, 0.26] // timing animation for each view
|
||||
return durations[itemIndex]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user