Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed5aa2f8a8 | ||
|
|
d89e99654f | ||
|
|
a003cc01d1 |
@@ -41,18 +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)
|
||||
|
||||
// shadow.shadowOffset = k
|
||||
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>
|
||||
|
||||
+11
-11
@@ -50,17 +50,17 @@ extension DemoTableViewController {
|
||||
extension DemoTableViewController {
|
||||
|
||||
override func scrollViewDidScroll(scrollView: UIScrollView) {
|
||||
if scrollView.contentOffset.y < -25 {
|
||||
// buttonAnimation
|
||||
let viewControllers: [DemoViewController?] = navigationController?.viewControllers.map { $0 as? DemoViewController } ?? []
|
||||
|
||||
for viewController in viewControllers {
|
||||
if let rightButton = viewController?.navigationItem.rightBarButtonItem as? AnimatingBarButton {
|
||||
rightButton.animationSelected(false)
|
||||
}
|
||||
}
|
||||
popTransitionAnimation()
|
||||
}
|
||||
// if scrollView.contentOffset.y < -25 {
|
||||
// // buttonAnimation
|
||||
// let viewControllers: [DemoViewController?] = navigationController?.viewControllers.map { $0 as? DemoViewController } ?? []
|
||||
//
|
||||
// for viewController in viewControllers {
|
||||
// if let rightButton = viewController?.navigationItem.rightBarButtonItem as? AnimatingBarButton {
|
||||
// rightButton.animationSelected(false)
|
||||
// }
|
||||
// }
|
||||
// popTransitionAnimation()
|
||||
// }
|
||||
|
||||
scrollOffsetY = scrollView.contentOffset.y
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
[](http://twitter.com/Ramotion)
|
||||
[](https://cocoapods.org/pods/expanding-collection)
|
||||
[](http://cocoapods.org/pods/expanding-collection)
|
||||
[](https://cdn.rawgit.com/Ramotion/expanding-collection/master/docs/index.html)
|
||||
|
||||
[](https://github.com/Ramotion/expanding-collection)
|
||||
[](https://travis-ci.org/Ramotion/elastic-pull-to-update)
|
||||
[](https://codebeat.co/projects/github-com-ramotion-expanding-collection)
|
||||
@@ -25,7 +27,7 @@ Just add the Source folder to your project.
|
||||
|
||||
or use [CocoaPods](https://cocoapods.org) with Podfile:
|
||||
``` ruby
|
||||
pod 'expanding-collection'
|
||||
pod 'expanding-collection'
|
||||
```
|
||||
or [Carthage](https://github.com/Carthage/Carthage) users can simply add to their `Cartfile`:
|
||||
```
|
||||
|
||||
@@ -24,10 +24,22 @@ extension ExpandingTableViewController {
|
||||
|
||||
private func getScreen() -> UIImage? {
|
||||
let height = (headerHeight - tableView.contentOffset.y) < 0 ? 0 : (headerHeight - tableView.contentOffset.y)
|
||||
let backImageSize = CGSize(width: view.bounds.width, height: view.bounds.height - height)
|
||||
let backImageSize = CGSize(width: view.bounds.width, height: view.bounds.height - height + getTabBarHeight())
|
||||
let backImageOrigin = CGPoint(x: 0, y: height + tableView.contentOffset.y)
|
||||
return view.takeSnapshot(CGRect(origin: backImageOrigin, size: backImageSize))
|
||||
}
|
||||
|
||||
private func getTabBarHeight() -> CGFloat {
|
||||
guard let navigationController = self.navigationController else {
|
||||
return 0
|
||||
}
|
||||
|
||||
let insets = automaticallyAdjustsScrollViewInsets
|
||||
let tabBarHeight = insets == true ? navigationController.navigationBar.frame.size.height : 0
|
||||
let stausBarHeight = insets == true ? UIApplication.sharedApplication().statusBarFrame.size.height : 0
|
||||
return tabBarHeight + stausBarHeight
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Methods
|
||||
@@ -43,7 +55,10 @@ extension ExpandingTableViewController {
|
||||
}
|
||||
|
||||
let backImage = getScreen()
|
||||
let offset = tableView.contentOffset.y > headerHeight ? headerHeight : tableView.contentOffset.y
|
||||
var offset = tableView.contentOffset.y > headerHeight ? headerHeight : tableView.contentOffset.y
|
||||
|
||||
offset += getTabBarHeight()
|
||||
|
||||
transitionDriver.popTransitionAnimationContantOffset(offset, backImage: backImage)
|
||||
self.navigationController?.popViewControllerAnimated(false)
|
||||
}
|
||||
|
||||
@@ -53,17 +53,22 @@ public extension ExpandingViewController {
|
||||
- parameter viewController: The table view controller to push onto the stack.
|
||||
*/
|
||||
func pushToViewController(viewController: ExpandingTableViewController) {
|
||||
guard let collectionView = self.collectionView else {
|
||||
guard let collectionView = self.collectionView,
|
||||
let navigationController = self.navigationController else {
|
||||
return
|
||||
}
|
||||
|
||||
viewController.transitionDriver = transitionDriver
|
||||
let insets = viewController.automaticallyAdjustsScrollViewInsets
|
||||
let tabBarHeight = insets == true ? navigationController.navigationBar.frame.size.height : 0
|
||||
let stausBarHeight = insets == true ? UIApplication.sharedApplication().statusBarFrame.size.height : 0
|
||||
let backImage = getBackImage(viewController, headerHeight: viewController.headerHeight)
|
||||
|
||||
transitionDriver?.pushTransitionAnimationIndex(currentIndex,
|
||||
collecitionView: collectionView,
|
||||
backImage: backImage,
|
||||
headerHeight: viewController.headerHeight) { headerView in
|
||||
headerHeight: viewController.headerHeight,
|
||||
insets: tabBarHeight + stausBarHeight) { headerView in
|
||||
viewController.tableView.tableHeaderView = headerView
|
||||
self.navigationController?.pushViewController(viewController, animated: false)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ extension TransitionDriver {
|
||||
collecitionView: UICollectionView,
|
||||
backImage: UIImage?,
|
||||
headerHeight: CGFloat,
|
||||
insets: CGFloat,
|
||||
completion: UIView -> Void) {
|
||||
|
||||
guard case let cell as BasePageCollectionCell = collecitionView.cellForItemAtIndexPath(NSIndexPath(forRow: currentIndex, inSection: 0)),
|
||||
@@ -60,8 +61,8 @@ extension TransitionDriver {
|
||||
configurateCell(copyView, backImage: backImage)
|
||||
backImageView = addImageToView(copyView.backContainerView, image: backImage)
|
||||
|
||||
openBackViewConfigureConstraints(copyView, height: headerHeight)
|
||||
openFrontViewConfigureConstraints(copyView, height: headerHeight)
|
||||
openBackViewConfigureConstraints(copyView, height: headerHeight, insets: insets)
|
||||
openFrontViewConfigureConstraints(copyView, height: headerHeight, insets: insets)
|
||||
|
||||
// corner animation
|
||||
copyView.backContainerView.animationCornerRadius(0, duration: duration)
|
||||
@@ -188,7 +189,7 @@ extension TransitionDriver {
|
||||
|
||||
extension TransitionDriver {
|
||||
|
||||
private func openFrontViewConfigureConstraints(cell: BasePageCollectionCell, height: CGFloat) {
|
||||
private func openFrontViewConfigureConstraints(cell: BasePageCollectionCell, height: CGFloat, insets: CGFloat) {
|
||||
|
||||
if let heightConstraint = cell.frontContainerView.getConstraint(.Height) {
|
||||
frontViewFrame.size.height = heightConstraint.constant
|
||||
@@ -201,10 +202,10 @@ extension TransitionDriver {
|
||||
}
|
||||
|
||||
frontViewFrame.origin.y = cell.frontConstraintY.constant
|
||||
cell.frontConstraintY.constant = -view.bounds.size.height / 2 + height / 2
|
||||
cell.frontConstraintY.constant = -view.bounds.size.height / 2 + height / 2 + insets
|
||||
}
|
||||
|
||||
private func openBackViewConfigureConstraints(cell: BasePageCollectionCell, height: CGFloat) {
|
||||
private func openBackViewConfigureConstraints(cell: BasePageCollectionCell, height: CGFloat, insets: CGFloat) {
|
||||
|
||||
if let heightConstraint = cell.backContainerView.getConstraint(.Height) {
|
||||
backViewFrame.size.height = heightConstraint.constant
|
||||
@@ -217,7 +218,7 @@ extension TransitionDriver {
|
||||
}
|
||||
|
||||
backViewFrame.origin.y = cell.backConstraintY.constant
|
||||
cell.backConstraintY.constant = view.bounds.size.height / 2 - (view.bounds.size.height - 236) / 2
|
||||
cell.backConstraintY.constant = view.bounds.size.height / 2 - (view.bounds.size.height - 236) / 2 + insets
|
||||
}
|
||||
|
||||
private func closeBackViewConfigurationConstraints(cell: BasePageCollectionCell?) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'expanding-collection'
|
||||
s.version = '0.0.6'
|
||||
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