• Stars
    star
    388
  • Rank 110,734 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A page view controller component that reproduces Mobile Safari's tab switching behavior

SCSafariPageController

SCSafariPageController page view controller component that reproduces the behavior seen in Mobile Safari's tab switcher and is intended as a demo for SCPageViewController

Features:

  • can zoom out, partially overlap and lean in pages similar to Safari
  • can zoom in and focus on any of the pages and animates the layout change
  • allows swipe to delete on one or multiple pages at the same time
  • dynamically adapts the inter-item spacings and page angles based on the total number of pages, even while swiping to delete
  • increases the page angles when scrolling outside its bounds
  • supports incremental updates

and all the rest of the SCPageViewController niceties.

Implementation details

SCSafariPageController is built on top of SCPageViewController and makes use of custom page layouters to get the desired effects.

It wraps view controllers inside the scroll view based SCSafariPageWrapperViewController to get the slide to delete feature and then applies variable inter-item spacings and sublayer transforms (angle, perspective and scale) to the pages, based on the total number of pages and the content offset.

Usage

  • Create a new instance and register as its data source and, optionally, delegate
    self.safariPageController = [[SCSafariPageController alloc] init];
	[self.safariPageController setDataSource:self];
	[self.safariPageController setDelegate:self];
  • Implement the SCSafariPageControllerDateSource protocol to define the total number of pages and the view controllers to be used for each of them
- (NSUInteger)numberOfPagesInPageController:(SCSafariPageController *)pageController;

- (UIViewController *)pageController:(SCSafariPageController *)pageController viewControllerForPageAtIndex:(NSUInteger)index;
  • Optionally, listen to any of the following delegate events
- (void)pageController:(SCSafariPageController *)pageController didShowViewController:(UIViewController *)controller atIndex:(NSUInteger)index;

- (void)pageController:(SCSafariPageController *)pageController didHideViewController:(UIViewController *)controller atIndex:(NSUInteger)index;
			  
- (void)pageController:(SCSafariPageController *)pageController didNavigateToOffset:(CGPoint)offset;
   
- (void)pageController:(SCSafariPageController *)pageController didNavigateToPageAtIndex:(NSUInteger)pageIndex;

- (void)pageController:(SCSafariPageController *)pageController willDeletePageAtIndex:(NSUInteger)pageIndex;

- (void)pageController:(SCSafariPageController *)pageController didDeletePageAtIndex:(NSUInteger)pageIndex;
  • Zoom in and out
- (void)zoomOutAnimated:(BOOL)animated completion:(void(^)())completion;

- (void)zoomIntoPageAtIndex:(NSUInteger)index animated:(BOOL)animated completion:(void(^)())completion;
  • SCSafariPageController also supports incremental updates with animations that are customizable through its active layouter
	[self.safariPageController insertPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion];

	[self.safariPageController deletePagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion]

	[self.safariPageController reloadPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion]

	[self.safariPageController movePageAtIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex animated:(BOOL)animated completion:^(void)completion]

For more usage examples please have a look at the included demo project (pod try SCSafariPageController)

License

SCSafariPageController is released under the MIT License (MIT) (see the LICENSE file)

Contact

Any suggestions or improvements are more than welcome and I would also love to know if you are using this component in a published application. Feel free to contact me at [email protected] or @stefanceriu.

More Repositories

1

SCSiriWaveformView

UIView subclass that reproduces the waveform effect seen in Siri on iOS 7.
Objective-C
1,090
star
2

SCXcodeMiniMap

Sublime Text like Minimap for Xcode
Objective-C
1,026
star
3

SCXcodeSwitchExpander

Xcode plugin that enables switch cases autocompletion
Objective-C
655
star
4

SCStringsUtility

OS X / iOS Translations helper
Objective-C
526
star
5

SCPageViewController

Just like UIPageViewController but better.. :)
Objective-C
353
star
6

SCStackViewController

SCStackViewController is a container view controller which allows you to stack other view controllers on the top/left/bottom/right of the root and build custom transitions between them while providing correct physics and appearance calls.
Objective-C
265
star
7

SCSkypeActivityIndicatorView

Activity indicator view similar to the one seen in the Skype apps.
Objective-C
106
star
8

SCXcodeEditorInset

Xcode plugin that adds an empty (configurable) space to the end of the editor text view
Objective-C
63
star
9

SCNavigationController

SCNavigationController is an UINavigationController like container view controller and was built to provide and expose more features and control
Objective-C
46
star
10

SCXcodeTabSwitcher

Enables changing Xcode tabs using the ⌘cmd + [1..9] keys
Objective-C
42
star
11

SCScrollView

UIScrollView subclass that can use a custom easing function to animate the setting of the content offset
Objective-C
20
star
12

Xcode-Headers

Xcode headers dump
Objective-C
18
star
13

UIScrollView-ScrollerAdditions

Customising UIScrollView's scroll bars
Objective-C
17
star
14

SCDragController

SCDragController is a component meant to aid the development of drag & drop behaviors.
Objective-C
10
star
15

SCMarsRover

Simple cocoa application that provides a visual implementation to the Thoughtworks Mars Rover problem
Objective-C
1
star