Skip to content

UIViewController subclass inspired by "Inbox by google" animated transitioning.

License

Notifications You must be signed in to change notification settings

mohsinalimat/SAInboxViewController

 
 

Repository files navigation

SAInboxViewController

Platform Language Version License

SAInboxViewController realizes Inbox like view transitioning.

Features

  • Inbox like view transitioning
  • Scrolling up to begining of contents transitioning
  • Scrolling down to end of contents transitioning
  • Header dragging transitioning
  • Left edge swiping transitioning

Installation

CocoaPods

SAHistoryNavigationViewController is available through CocoaPods. If you have cocoapods 0.36.1 or greater, you can install it, simply add the following line to your Podfile:

pod "SAInboxViewController"

Manually

Add the SAInboxViewController directory to your project.

Usage

If you install from cocoapods, you have to write import SAInboxViewController.

First of all, please use SAInboxViewController with UINavigationController.

There are two ViewControllers to realize Inbox transitioning. Please extend those ViewControllers.

  1. SAInboxViewController... using as rootViewController
  2. SAInboxDetailViewController... using as second ViewController

Those ViewControllers have UITableView, so implement ordinary UITableView behavior with that tableView.

If you use UITableViewDelegate in ViewController which extends SAInboxDetailViewController, please call super methods for below two methods.

override func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
    super.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}

override func scrollViewDidScroll(scrollView: UIScrollView) {
	super.scrollViewDidScroll(scrollView)
}

If you want to present ViewController from rootViewController, implement func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) like this.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let viewController = SAInboxDetailViewController()
    if let cell = tableView.cellForRowAtIndexPath(indexPath), cells = tableView.visibleCells() as? [UITableViewCell] {
        SAInboxAnimatedTransitioningController.sharedInstance().configureCotainerView(view, cell: cell, cells: cells, headerImage: headerView.screenshotImage())
    }        
    navigationController?.pushViewController(viewController, animated: true)
}

Implement UINavigationControllerDelegate methods, like this.

func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return SAInboxAnimatedTransitioningController.sharedInstance().setOperation(operation)
}

Customize

You can change HeaderView barTintColor, tintColor and titleTextAttributes.
There are 2 ways to change HeaderView Appearance.

Application Base Appearance

SAInboxViewController class has Appearance property

SAInboxViewController.appearance.barTintColor = .blackColor()
SAInboxViewController.appearance.tintColor = .whiteColor()
SAInboxViewController.appearance.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]

ViewController Base Appearance

SAInboxViewController instance has Appearance property.

override func viewDidLoad() {
    super.viewDidLoad()
    appearance.barTintColor = .whiteColor()
    appearance.tintColor = .blackColor()
    appearance.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.blackColor()]
    
    //Do not forget to set true
    enabledViewControllerBasedAppearance = true
}

Requirements

  • Xcode 6.4 or greater
  • iOS7.0(manually only) or greater

Author

Taiki Suzuki, [email protected]

License

SAInboxViewController is available under the MIT license. See the LICENSE file for more info.

About

UIViewController subclass inspired by "Inbox by google" animated transitioning.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 82.7%
  • Shell 12.8%
  • Ruby 2.5%
  • Objective-C 1.1%
  • C 0.9%