Compare commits

...
2 Commits
Author SHA1 Message Date
Alex.k d89e99654f Fixes #14 2016-06-07 16:29:44 +03:00
Alex.k a003cc01d1 update readme 2016-06-07 11:37:26 +03:00
7 changed files with 46 additions and 24 deletions
@@ -49,7 +49,6 @@ extension AppDelegate {
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
@@ -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
}
+3 -1
View File
@@ -5,6 +5,8 @@
[![Twitter](https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat)](http://twitter.com/Ramotion)
[![CocoaPods](https://img.shields.io/cocoapods/p/expanding-collection.svg)](https://cocoapods.org/pods/expanding-collection)
[![CocoaPods](https://img.shields.io/cocoapods/v/expanding-collection.svg)](http://cocoapods.org/pods/expanding-collection)
[![CocoaPods](https://img.shields.io/cocoapods/metrics/doc-percent/expanding-collection.svg)](https://cdn.rawgit.com/Ramotion/expanding-collection/master/docs/index.html)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Ramotion/expanding-collection)
[![Travis](https://travis-ci.org/Ramotion/elastic-pull-to-update.svg?branch=master)](https://travis-ci.org/Ramotion/elastic-pull-to-update)
[![codebeat badge](https://codebeat.co/badges/6a009992-5bf2-4730-aa35-f3b20ce7693d)](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 -1
View File
@@ -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'