Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed5aa2f8a8 |
@@ -41,17 +41,17 @@ extension AppDelegate {
|
||||
|
||||
private func configureNavigationTabBar() {
|
||||
//transparent background
|
||||
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
|
||||
UINavigationBar.appearance().shadowImage = UIImage()
|
||||
UINavigationBar.appearance().translucent = true
|
||||
|
||||
let shadow = NSShadow()
|
||||
shadow.shadowOffset = CGSize(width: 0, height: 2)
|
||||
shadow.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1)
|
||||
|
||||
UINavigationBar.appearance().titleTextAttributes = [
|
||||
NSForegroundColorAttributeName : UIColor.whiteColor(),
|
||||
NSShadowAttributeName: shadow
|
||||
]
|
||||
// UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
|
||||
// UINavigationBar.appearance().shadowImage = UIImage()
|
||||
// UINavigationBar.appearance().translucent = true
|
||||
//
|
||||
// let shadow = NSShadow()
|
||||
// shadow.shadowOffset = CGSize(width: 0, height: 2)
|
||||
// shadow.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1)
|
||||
//
|
||||
// UINavigationBar.appearance().titleTextAttributes = [
|
||||
// NSForegroundColorAttributeName : UIColor.whiteColor(),
|
||||
// NSShadowAttributeName: shadow
|
||||
// ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<!--Demo Table View Controller-->
|
||||
<scene sceneID="7Xk-ar-e7L">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="DemoTableViewController" automaticallyAdjustsScrollViewInsets="NO" id="7RW-i0-HfN" customClass="DemoTableViewController" customModule="DemoExpandingCollection" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableViewController storyboardIdentifier="DemoTableViewController" id="7RW-i0-HfN" customClass="DemoTableViewController" customModule="DemoExpandingCollection" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="static" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="2SU-lJ-2AP">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
@@ -109,7 +109,7 @@
|
||||
<tableViewSection id="IIl-eL-sK9">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CustomTableViewCell" rowHeight="124" id="SFA-X2-Rbf">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="44" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="SFA-X2-Rbf" id="RQr-Ti-ps0">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
@@ -146,7 +146,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="124" id="ew1-hI-ark">
|
||||
<rect key="frame" x="0.0" y="124" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="168" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ew1-hI-ark" id="tMC-aw-BE2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
@@ -201,7 +201,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="124" id="0ee-7A-I2I">
|
||||
<rect key="frame" x="0.0" y="248" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="292" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0ee-7A-I2I" id="jPx-eH-c2S">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
@@ -256,7 +256,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="124" id="fTH-KP-Ac5">
|
||||
<rect key="frame" x="0.0" y="372" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="416" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="fTH-KP-Ac5" id="BGd-Mp-TnE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
@@ -311,7 +311,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="124" id="irZ-0L-X9r">
|
||||
<rect key="frame" x="0.0" y="496" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="540" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="irZ-0L-X9r" id="t3x-Eb-ktg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
@@ -366,7 +366,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="124" id="Fj4-n4-S6M">
|
||||
<rect key="frame" x="0.0" y="620" width="600" height="124"/>
|
||||
<rect key="frame" x="0.0" y="664" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Fj4-n4-S6M" id="D8J-AG-YUN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
+1
-3
@@ -22,7 +22,6 @@ class DemoViewController: ExpandingViewController {
|
||||
extension DemoViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
itemSize = CGSize(width: 256, height: 335)
|
||||
super.viewDidLoad()
|
||||
|
||||
registerCell()
|
||||
@@ -105,8 +104,7 @@ extension DemoViewController {
|
||||
|
||||
extension DemoViewController {
|
||||
|
||||
override func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
super.collectionView(collectionView, willDisplayCell: cell, forItemAtIndexPath: indexPath)
|
||||
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
guard let cell = cell as? DemoCollectionViewCell else { return }
|
||||
|
||||
let index = indexPath.row % items.count
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||

|
||||

|
||||
|
||||
# expanding-collection
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[](https://codebeat.co/projects/github-com-ramotion-expanding-collection)
|
||||
|
||||
[shot on dribbble](https://dribbble.com/shots/2741477-iOS-Expanding-Collection-Open-Source):
|
||||

|
||||

|
||||
|
||||
The [iPhone mockup](https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection) available [here](https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection).
|
||||
|
||||
@@ -37,11 +37,11 @@ github "Ramotion/expanding-collection"
|
||||
## Usage
|
||||
|
||||
```swift
|
||||
import ExpandingCollection
|
||||
import expanding_collection
|
||||
```
|
||||
|
||||
#### Create CollectionViewCell
|
||||

|
||||

|
||||
|
||||
1) Create UICollectionViewCell inherit from `BasePageCollectionCell` (recommend create cell with xib file)
|
||||
|
||||
@@ -49,7 +49,7 @@ import ExpandingCollection
|
||||
- add a view to YOURCELL.xib and connect it to `@IBOutlet weak var frontContainerView: UIView!`
|
||||
- add width, height, centerX and centerY constraints (width and height constranints must equal cellSize)
|
||||
|
||||

|
||||

|
||||
- connect centerY constraint to `@IBOutlet weak var frontConstraintY: NSLayoutConstraint!`
|
||||
- add any desired uiviews to frontView
|
||||
|
||||
@@ -113,24 +113,6 @@ func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath i
|
||||
}
|
||||
```
|
||||
|
||||
###### if you use this delegates method:
|
||||
```Swift
|
||||
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView)
|
||||
```
|
||||
###### must call super method:
|
||||
```Swift
|
||||
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
super.collectionView(collectionView: collectionView, willDisplayCell cell: cell, forItemAtIndexPath indexPath: indexPath)
|
||||
// code
|
||||
}
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
|
||||
super.scrollViewDidEndDecelerating(scrollView: scrollView)
|
||||
// code
|
||||
}
|
||||
```
|
||||
#### Transition animation
|
||||
|
||||
1) Create a UITableViewController inheriting from `ExpandingTableViewController`
|
||||
|
||||
@@ -101,20 +101,17 @@ extension BasePageCollectionCell {
|
||||
public func cellIsOpen(isOpen: Bool, animated: Bool = true) {
|
||||
if isOpen == isOpened { return }
|
||||
|
||||
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 5 : 0
|
||||
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 5 - yOffset / 2 : 0
|
||||
frontConstraintY.constant = isOpen == true ? -bounds.size.height / 5 : 0
|
||||
backConstraintY.constant = isOpen == true ? bounds.size.height / 5 - yOffset / 2 : 0
|
||||
|
||||
if let widthConstant = backContainerView.getConstraint(.Width) {
|
||||
widthConstant.constant = isOpen == true ? frontContainerView.bounds.size.width + yOffset : frontContainerView.bounds.size.width
|
||||
widthConstant.constant = isOpen == true ? contentView.bounds.size.width + yOffset : contentView.bounds.size.width
|
||||
}
|
||||
|
||||
if let heightConstant = backContainerView.getConstraint(.Height) {
|
||||
heightConstant.constant = isOpen == true ? frontContainerView.bounds.size.height + yOffset : frontContainerView.bounds.size.height
|
||||
heightConstant.constant = isOpen == true ? contentView.bounds.size.height + yOffset : contentView.bounds.size.height
|
||||
}
|
||||
|
||||
configurationCell()
|
||||
|
||||
|
||||
if animated == true {
|
||||
UIView.animateWithDuration(0.3, delay: 0, options: .CurveEaseInOut, animations: {
|
||||
self.contentView.layoutIfNeeded()
|
||||
@@ -181,31 +178,6 @@ extension BasePageCollectionCell {
|
||||
|
||||
return shadow
|
||||
}
|
||||
|
||||
|
||||
func configurationCell() {
|
||||
// Prevents indefinite growing of the cell issue
|
||||
let i: CGFloat = self.isOpened ? 1 : -1
|
||||
let superHeight = superview?.frame.size.height ?? 0
|
||||
|
||||
frame.size.height += i * superHeight
|
||||
frame.origin.y -= i * superHeight / 2
|
||||
frame.origin.x -= i * yOffset / 2
|
||||
frame.size.width += i * yOffset
|
||||
}
|
||||
|
||||
|
||||
func configureCellViewConstraintsWithSize(size: CGSize) {
|
||||
guard isOpened == false && frontContainerView.getConstraint(.Width)?.constant != size.width else { return }
|
||||
|
||||
[frontContainerView, backContainerView].forEach {
|
||||
let constraintWidth = $0.getConstraint(.Width)
|
||||
constraintWidth?.constant = size.width
|
||||
|
||||
let constraintHeight = $0.getConstraint(.Height)
|
||||
constraintHeight?.constant = size.height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: NSCoding
|
||||
|
||||
@@ -105,15 +105,8 @@ extension ExpandingViewController {
|
||||
|
||||
// MARK: UICollectionViewDataSource
|
||||
|
||||
extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewDelegate {
|
||||
extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewDelegate{
|
||||
|
||||
public func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
guard case let cell as BasePageCollectionCell = cell else {
|
||||
return
|
||||
}
|
||||
|
||||
cell.configureCellViewConstraintsWithSize(itemSize)
|
||||
}
|
||||
public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
fatalError("need emplementation in subclass")
|
||||
}
|
||||
@@ -123,15 +116,3 @@ extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewD
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: UIScrollViewDelegate
|
||||
|
||||
extension ExpandingViewController {
|
||||
|
||||
public func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
|
||||
let indexPath = NSIndexPath(forRow: currentIndex, inSection: 0)
|
||||
if case let currentCell as BasePageCollectionCell = collectionView?.cellForItemAtIndexPath(indexPath) {
|
||||
currentCell.configurationCell()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@@ -364,7 +364,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
+4
-146
@@ -46,157 +46,15 @@
|
||||
<section>
|
||||
<section class="section">
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/header.png" alt="header"></p>
|
||||
<a href='#expanding_collection' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='expanding_collection'>expanding-collection</h1>
|
||||
<a href='#demoexpandingcollection' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='demoexpandingcollection'>DemoExpandingCollection</h1>
|
||||
<a href='#authors' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='authors'>Authors</h3>
|
||||
|
||||
<p><a href="http://twitter.com/Ramotion"><img src="https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat" alt="Twitter"></a>
|
||||
<a href="https://cocoapods.org/pods/expanding-collection"><img src="https://img.shields.io/cocoapods/p/expanding-collection.svg" alt="CocoaPods"></a>
|
||||
<a href="http://cocoapods.org/pods/expanding-collection"><img src="https://img.shields.io/cocoapods/v/expanding-collection.svg" alt="CocoaPods"></a>
|
||||
<a href="https://cdn.rawgit.com/Ramotion/expanding-collection/master/docs/index.html"><img src="https://img.shields.io/cocoapods/metrics/doc-percent/expanding-collection.svg" alt="CocoaPods"></a></p>
|
||||
|
||||
<p><a href="https://github.com/Ramotion/expanding-collection"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a>
|
||||
<a href="https://travis-ci.org/Ramotion/elastic-pull-to-update"><img src="https://travis-ci.org/Ramotion/elastic-pull-to-update.svg?branch=master" alt="Travis"></a>
|
||||
<a href="https://codebeat.co/projects/github-com-ramotion-expanding-collection"><img src="https://codebeat.co/badges/6a009992-5bf2-4730-aa35-f3b20ce7693d" alt="codebeat badge"></a></p>
|
||||
|
||||
<p><a href="https://dribbble.com/shots/2741477-iOS-Expanding-Collection-Open-Source">shot on dribbble</a>:
|
||||
<img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/preview.gif" alt="Animation"></p>
|
||||
|
||||
<p>The <a href="https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">iPhone mockup</a> available <a href="https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">here</a>.</p>
|
||||
<a href='#requirements' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='requirements'>Requirements</h2>
|
||||
|
||||
<ul>
|
||||
<li>iOS 8.0+</li>
|
||||
<li>Xcode 7.3</li>
|
||||
</ul>
|
||||
<a href='#installation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='installation'>Installation</h2>
|
||||
|
||||
<p>Just add the Source folder to your project.</p>
|
||||
|
||||
<p>or use <a href="https://cocoapods.org">CocoaPods</a> with Podfile:
|
||||
<code>ruby
|
||||
pod 'expanding-collection'
|
||||
</code>
|
||||
or <a href="https://github.com/Carthage/Carthage">Carthage</a> users can simply add to their <code>Cartfile</code>:
|
||||
<code>
|
||||
github "Ramotion/expanding-collection"
|
||||
</code></p>
|
||||
<a href='#usage' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='usage'>Usage</h2>
|
||||
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">ExpandingCollection</span>
|
||||
</code></pre>
|
||||
<a href='#create_collectionviewcell' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='create_collectionviewcell'>Create CollectionViewCell</h4>
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/images/image2.png" alt="cell"></p>
|
||||
|
||||
<p>1) Create UICollectionViewCell inherit from <code>BasePageCollectionCell</code> (recommend create cell with xib file)</p>
|
||||
|
||||
<p>2) Adding FrontView
|
||||
- add a view to YOURCELL.xib and connect it to <code>@IBOutlet weak var frontContainerView: UIView!</code><br>
|
||||
- add width, height, centerX and centerY constraints (width and height constranints must equal cellSize)</p>
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/images/image1.png" alt="cell"><br>
|
||||
- connect centerY constraint to <code>@IBOutlet weak var frontConstraintY: NSLayoutConstraint!</code>
|
||||
- add any desired uiviews to frontView</p>
|
||||
|
||||
<p>3) Adding BackView
|
||||
- repeat step 2 (connect outlets to <code>@IBOutlet weak var backContainerView: UIView!</code>, <code>@IBOutlet weak var backConstraintY: NSLayoutConstraint!</code>)</p>
|
||||
|
||||
<p>4) Cell example <a href="https://github.com/Ramotion/expanding-collection/tree/master/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/Cells">DemoCell</a></p>
|
||||
<a href='#if_set_code_tag_101_code_for_any_code_frontview_subviews_code_this_view_will_be_hidden_during_the_transition_animation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='if_set_code_tag_101_code_for_any_code_frontview_subviews_code_this_view_will_be_hidden_during_the_transition_animation'>If set <code>tag = 101</code> for any <code>FrontView.subviews</code> this view will be hidden during the transition animation</h6>
|
||||
<a href='#create_collectionviewcontroller' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='create_collectionviewcontroller'>Create CollectionViewController</h4>
|
||||
|
||||
<p>1) Create a UIViewController inheriting from <code>ExpandingViewController</code></p>
|
||||
|
||||
<p>2) Register Cell and set Cell size:</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="n">itemSize</span> <span class="o">=</span> <span class="kt">CGSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="mi">214</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">264</span><span class="p">)</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
|
||||
<span class="c1">// register cell</span>
|
||||
<span class="k">let</span> <span class="nv">nib</span> <span class="o">=</span> <span class="kt">UINib</span><span class="p">(</span><span class="nv">nibName</span><span class="p">:</span> <span class="s">"NibName"</span><span class="p">,</span> <span class="nv">bundle</span><span class="p">:</span> <span class="kc">nil</span><span class="p">)</span>
|
||||
<span class="n">collectionView</span><span class="p">?</span><span class="o">.</span><span class="nf">registerNib</span><span class="p">(</span><span class="n">nib</span><span class="p">,</span> <span class="nv">forCellWithReuseIdentifier</span><span class="p">:</span> <span class="s">"CellIdentifier"</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>3) Add UICollectionViewDataSource methods</p>
|
||||
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt">YourViewController</span> <span class="p">{</span>
|
||||
|
||||
<span class="k">override</span> <span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">numberOfItemsInSection</span> <span class="nv">section</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="n">items</span><span class="o">.</span><span class="n">count</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">override</span> <span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">cellForItemAtIndexPath</span> <span class="nv">indexPath</span><span class="p">:</span> <span class="kt">NSIndexPath</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UICollectionViewCell</span> <span class="p">{</span>
|
||||
<span class="k">let</span> <span class="nv">cell</span> <span class="o">=</span> <span class="n">collectionView</span><span class="o">.</span><span class="nf">dequeueReusableCellWithReuseIdentifier</span><span class="p">(</span><span class="s">"CellIdentifier"</span><span class="p">),</span> <span class="nv">forIndexPath</span><span class="p">:</span> <span class="n">indexPath</span><span class="p">)</span>
|
||||
<span class="c1">// configure cell</span>
|
||||
<span class="k">return</span> <span class="n">cell</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>4) Open Cell animation</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="n">itemSize</span> <span class="o">=</span> <span class="kt">CGSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="mi">214</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">264</span><span class="p">)</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
|
||||
<span class="c1">// register cell</span>
|
||||
<span class="k">let</span> <span class="nv">nib</span> <span class="o">=</span> <span class="kt">UINib</span><span class="p">(</span><span class="nv">nibName</span><span class="p">:</span> <span class="s">"CellIdentifier"</span><span class="p">,</span> <span class="nv">bundle</span><span class="p">:</span> <span class="kc">nil</span><span class="p">)</span>
|
||||
<span class="n">collectionView</span><span class="p">?</span><span class="o">.</span><span class="nf">registerNib</span><span class="p">(</span><span class="n">nib</span><span class="p">,</span> <span class="nv">forCellWithReuseIdentifier</span><span class="p">:</span> <span class="kt">String</span><span class="p">(</span><span class="kt">DemoCollectionViewCell</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">didSelectItemAtIndexPath</span> <span class="nv">indexPath</span><span class="p">:</span> <span class="kt">NSIndexPath</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">cell</span><span class="o">.</span><span class="nf">cellIsOpen</span><span class="p">(</span><span class="o">!</span><span class="n">cell</span><span class="o">.</span><span class="n">isOpened</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<a href='#if_you_use_this_delegates_method' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='if_you_use_this_delegates_method'>if you use this delegates method:</h6>
|
||||
<pre class="highlight plaintext"><code>func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView)
|
||||
</code></pre>
|
||||
<a href='#must_call_super_method' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='must_call_super_method'>must call super method:</h6>
|
||||
<pre class="highlight plaintext"><code>func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
super.collectionView(collectionView: collectionView, willDisplayCell cell: cell, forItemAtIndexPath indexPath: indexPath)
|
||||
// code
|
||||
}
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
|
||||
super.scrollViewDidEndDecelerating(scrollView: scrollView)
|
||||
// code
|
||||
}
|
||||
</code></pre>
|
||||
<a href='#transition_animation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='transition_animation'>Transition animation</h4>
|
||||
|
||||
<p>1) Create a UITableViewController inheriting from <code>ExpandingTableViewController</code></p>
|
||||
|
||||
<p>2) Set header height default 236</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
<span class="n">headerHeight</span> <span class="o">=</span> <span class="o">***</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>3) Call the push method in YourViewController to YourTableViewController</p>
|
||||
<pre class="highlight swift"><code> <span class="k">if</span> <span class="n">cell</span><span class="o">.</span><span class="n">isOpened</span> <span class="o">==</span> <span class="kc">true</span> <span class="p">{</span>
|
||||
<span class="k">let</span> <span class="nv">vc</span><span class="p">:</span> <span class="kt">YourTableViewController</span> <span class="o">=</span> <span class="c1">// ... create view controller </span>
|
||||
<span class="nf">pushToViewController</span><span class="p">(</span><span class="n">vc</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>4) For back transition use <code>popTransitionAnimation()</code></p>
|
||||
<a href='#license' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='license'>License</h2>
|
||||
|
||||
<p>Expanding collection is released under the MIT license.
|
||||
See <a href="./LICENSE">LICENSE</a> for details.</p>
|
||||
<a href='#about' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='about'>About</h2>
|
||||
|
||||
<p>The project maintained by <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">app development agency</a> <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">Ramotion Inc.</a>
|
||||
See our other <a href="https://github.com/ramotion">open-source projects</a> or <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">hire</a> us to design, develop, and grow your product.</p>
|
||||
|
||||
<p><a href="https://twitter.com/intent/tweet?text=https://github.com/ramotion/expanding-collection"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social" alt="Twitter URL"></a>
|
||||
<a href="https://twitter.com/ramotion"><img src="https://img.shields.io/twitter/follow/ramotion.svg?style=social" alt="Twitter Follow"></a></p>
|
||||
<p>AlexKalinkin</p>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
Binary file not shown.
+4
-146
@@ -46,157 +46,15 @@
|
||||
<section>
|
||||
<section class="section">
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/header.png" alt="header"></p>
|
||||
<a href='#expanding_collection' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='expanding_collection'>expanding-collection</h1>
|
||||
<a href='#demoexpandingcollection' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='demoexpandingcollection'>DemoExpandingCollection</h1>
|
||||
<a href='#authors' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='authors'>Authors</h3>
|
||||
|
||||
<p><a href="http://twitter.com/Ramotion"><img src="https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat" alt="Twitter"></a>
|
||||
<a href="https://cocoapods.org/pods/expanding-collection"><img src="https://img.shields.io/cocoapods/p/expanding-collection.svg" alt="CocoaPods"></a>
|
||||
<a href="http://cocoapods.org/pods/expanding-collection"><img src="https://img.shields.io/cocoapods/v/expanding-collection.svg" alt="CocoaPods"></a>
|
||||
<a href="https://cdn.rawgit.com/Ramotion/expanding-collection/master/docs/index.html"><img src="https://img.shields.io/cocoapods/metrics/doc-percent/expanding-collection.svg" alt="CocoaPods"></a></p>
|
||||
|
||||
<p><a href="https://github.com/Ramotion/expanding-collection"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a>
|
||||
<a href="https://travis-ci.org/Ramotion/elastic-pull-to-update"><img src="https://travis-ci.org/Ramotion/elastic-pull-to-update.svg?branch=master" alt="Travis"></a>
|
||||
<a href="https://codebeat.co/projects/github-com-ramotion-expanding-collection"><img src="https://codebeat.co/badges/6a009992-5bf2-4730-aa35-f3b20ce7693d" alt="codebeat badge"></a></p>
|
||||
|
||||
<p><a href="https://dribbble.com/shots/2741477-iOS-Expanding-Collection-Open-Source">shot on dribbble</a>:
|
||||
<img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/preview.gif" alt="Animation"></p>
|
||||
|
||||
<p>The <a href="https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">iPhone mockup</a> available <a href="https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">here</a>.</p>
|
||||
<a href='#requirements' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='requirements'>Requirements</h2>
|
||||
|
||||
<ul>
|
||||
<li>iOS 8.0+</li>
|
||||
<li>Xcode 7.3</li>
|
||||
</ul>
|
||||
<a href='#installation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='installation'>Installation</h2>
|
||||
|
||||
<p>Just add the Source folder to your project.</p>
|
||||
|
||||
<p>or use <a href="https://cocoapods.org">CocoaPods</a> with Podfile:
|
||||
<code>ruby
|
||||
pod 'expanding-collection'
|
||||
</code>
|
||||
or <a href="https://github.com/Carthage/Carthage">Carthage</a> users can simply add to their <code>Cartfile</code>:
|
||||
<code>
|
||||
github "Ramotion/expanding-collection"
|
||||
</code></p>
|
||||
<a href='#usage' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='usage'>Usage</h2>
|
||||
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">ExpandingCollection</span>
|
||||
</code></pre>
|
||||
<a href='#create_collectionviewcell' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='create_collectionviewcell'>Create CollectionViewCell</h4>
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/images/image2.png" alt="cell"></p>
|
||||
|
||||
<p>1) Create UICollectionViewCell inherit from <code>BasePageCollectionCell</code> (recommend create cell with xib file)</p>
|
||||
|
||||
<p>2) Adding FrontView
|
||||
- add a view to YOURCELL.xib and connect it to <code>@IBOutlet weak var frontContainerView: UIView!</code><br>
|
||||
- add width, height, centerX and centerY constraints (width and height constranints must equal cellSize)</p>
|
||||
|
||||
<p><img src="https://raw.githubusercontent.com/Ramotion/expanding-collection/master/images/image1.png" alt="cell"><br>
|
||||
- connect centerY constraint to <code>@IBOutlet weak var frontConstraintY: NSLayoutConstraint!</code>
|
||||
- add any desired uiviews to frontView</p>
|
||||
|
||||
<p>3) Adding BackView
|
||||
- repeat step 2 (connect outlets to <code>@IBOutlet weak var backContainerView: UIView!</code>, <code>@IBOutlet weak var backConstraintY: NSLayoutConstraint!</code>)</p>
|
||||
|
||||
<p>4) Cell example <a href="https://github.com/Ramotion/expanding-collection/tree/master/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/Cells">DemoCell</a></p>
|
||||
<a href='#if_set_code_tag_101_code_for_any_code_frontview_subviews_code_this_view_will_be_hidden_during_the_transition_animation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='if_set_code_tag_101_code_for_any_code_frontview_subviews_code_this_view_will_be_hidden_during_the_transition_animation'>If set <code>tag = 101</code> for any <code>FrontView.subviews</code> this view will be hidden during the transition animation</h6>
|
||||
<a href='#create_collectionviewcontroller' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='create_collectionviewcontroller'>Create CollectionViewController</h4>
|
||||
|
||||
<p>1) Create a UIViewController inheriting from <code>ExpandingViewController</code></p>
|
||||
|
||||
<p>2) Register Cell and set Cell size:</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="n">itemSize</span> <span class="o">=</span> <span class="kt">CGSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="mi">214</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">264</span><span class="p">)</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
|
||||
<span class="c1">// register cell</span>
|
||||
<span class="k">let</span> <span class="nv">nib</span> <span class="o">=</span> <span class="kt">UINib</span><span class="p">(</span><span class="nv">nibName</span><span class="p">:</span> <span class="s">"NibName"</span><span class="p">,</span> <span class="nv">bundle</span><span class="p">:</span> <span class="kc">nil</span><span class="p">)</span>
|
||||
<span class="n">collectionView</span><span class="p">?</span><span class="o">.</span><span class="nf">registerNib</span><span class="p">(</span><span class="n">nib</span><span class="p">,</span> <span class="nv">forCellWithReuseIdentifier</span><span class="p">:</span> <span class="s">"CellIdentifier"</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>3) Add UICollectionViewDataSource methods</p>
|
||||
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt">YourViewController</span> <span class="p">{</span>
|
||||
|
||||
<span class="k">override</span> <span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">numberOfItemsInSection</span> <span class="nv">section</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="n">items</span><span class="o">.</span><span class="n">count</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">override</span> <span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">cellForItemAtIndexPath</span> <span class="nv">indexPath</span><span class="p">:</span> <span class="kt">NSIndexPath</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UICollectionViewCell</span> <span class="p">{</span>
|
||||
<span class="k">let</span> <span class="nv">cell</span> <span class="o">=</span> <span class="n">collectionView</span><span class="o">.</span><span class="nf">dequeueReusableCellWithReuseIdentifier</span><span class="p">(</span><span class="s">"CellIdentifier"</span><span class="p">),</span> <span class="nv">forIndexPath</span><span class="p">:</span> <span class="n">indexPath</span><span class="p">)</span>
|
||||
<span class="c1">// configure cell</span>
|
||||
<span class="k">return</span> <span class="n">cell</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>4) Open Cell animation</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="n">itemSize</span> <span class="o">=</span> <span class="kt">CGSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="mi">214</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">264</span><span class="p">)</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
|
||||
<span class="c1">// register cell</span>
|
||||
<span class="k">let</span> <span class="nv">nib</span> <span class="o">=</span> <span class="kt">UINib</span><span class="p">(</span><span class="nv">nibName</span><span class="p">:</span> <span class="s">"CellIdentifier"</span><span class="p">,</span> <span class="nv">bundle</span><span class="p">:</span> <span class="kc">nil</span><span class="p">)</span>
|
||||
<span class="n">collectionView</span><span class="p">?</span><span class="o">.</span><span class="nf">registerNib</span><span class="p">(</span><span class="n">nib</span><span class="p">,</span> <span class="nv">forCellWithReuseIdentifier</span><span class="p">:</span> <span class="kt">String</span><span class="p">(</span><span class="kt">DemoCollectionViewCell</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">collectionView</span><span class="p">(</span><span class="nv">collectionView</span><span class="p">:</span> <span class="kt">UICollectionView</span><span class="p">,</span> <span class="n">didSelectItemAtIndexPath</span> <span class="nv">indexPath</span><span class="p">:</span> <span class="kt">NSIndexPath</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">cell</span><span class="o">.</span><span class="nf">cellIsOpen</span><span class="p">(</span><span class="o">!</span><span class="n">cell</span><span class="o">.</span><span class="n">isOpened</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<a href='#if_you_use_this_delegates_method' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='if_you_use_this_delegates_method'>if you use this delegates method:</h6>
|
||||
<pre class="highlight plaintext"><code>func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView)
|
||||
</code></pre>
|
||||
<a href='#must_call_super_method' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h6 id='must_call_super_method'>must call super method:</h6>
|
||||
<pre class="highlight plaintext"><code>func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
||||
super.collectionView(collectionView: collectionView, willDisplayCell cell: cell, forItemAtIndexPath indexPath: indexPath)
|
||||
// code
|
||||
}
|
||||
|
||||
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
|
||||
super.scrollViewDidEndDecelerating(scrollView: scrollView)
|
||||
// code
|
||||
}
|
||||
</code></pre>
|
||||
<a href='#transition_animation' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h4 id='transition_animation'>Transition animation</h4>
|
||||
|
||||
<p>1) Create a UITableViewController inheriting from <code>ExpandingTableViewController</code></p>
|
||||
|
||||
<p>2) Set header height default 236</p>
|
||||
<pre class="highlight swift"><code><span class="k">override</span> <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
|
||||
<span class="n">headerHeight</span> <span class="o">=</span> <span class="o">***</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>3) Call the push method in YourViewController to YourTableViewController</p>
|
||||
<pre class="highlight swift"><code> <span class="k">if</span> <span class="n">cell</span><span class="o">.</span><span class="n">isOpened</span> <span class="o">==</span> <span class="kc">true</span> <span class="p">{</span>
|
||||
<span class="k">let</span> <span class="nv">vc</span><span class="p">:</span> <span class="kt">YourTableViewController</span> <span class="o">=</span> <span class="c1">// ... create view controller </span>
|
||||
<span class="nf">pushToViewController</span><span class="p">(</span><span class="n">vc</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>4) For back transition use <code>popTransitionAnimation()</code></p>
|
||||
<a href='#license' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='license'>License</h2>
|
||||
|
||||
<p>Expanding collection is released under the MIT license.
|
||||
See <a href="./LICENSE">LICENSE</a> for details.</p>
|
||||
<a href='#about' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='about'>About</h2>
|
||||
|
||||
<p>The project maintained by <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">app development agency</a> <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">Ramotion Inc.</a>
|
||||
See our other <a href="https://github.com/ramotion">open-source projects</a> or <a href="https://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection">hire</a> us to design, develop, and grow your product.</p>
|
||||
|
||||
<p><a href="https://twitter.com/intent/tweet?text=https://github.com/ramotion/expanding-collection"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social" alt="Twitter URL"></a>
|
||||
<a href="https://twitter.com/ramotion"><img src="https://img.shields.io/twitter/follow/ramotion.svg?style=social" alt="Twitter Follow"></a></p>
|
||||
<p>AlexKalinkin</p>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
<section id="footer">
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-10)</p>
|
||||
<p>© 2016 <a class="link" href="" target="_blank" rel="external">AlexKalinkin</a>. All rights reserved. (Last updated: 2016-06-07)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.5.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'expanding-collection'
|
||||
s.version = '0.3.0'
|
||||
s.version = '0.1.1'
|
||||
s.summary = 'Transition animtion from CollectionView to TableView'
|
||||
s.license = 'MIT'
|
||||
s.homepage = 'https://github.com/Ramotion/expanding-collection'
|
||||
|
||||
Reference in New Issue
Block a user