Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pronebird/custommodaltransition
Custom transitions on iOS 7 and iOS 8
https://github.com/pronebird/custommodaltransition
Last synced: 6 days ago
JSON representation
Custom transitions on iOS 7 and iOS 8
- Host: GitHub
- URL: https://github.com/pronebird/custommodaltransition
- Owner: pronebird
- Created: 2014-05-29T19:29:03.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-10T17:00:19.000Z (about 9 years ago)
- Last Synced: 2024-10-31T13:50:33.029Z (13 days ago)
- Language: Objective-C
- Homepage:
- Size: 769 KB
- Stars: 84
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Custom modal transition
=====================A custom transition I developed for one of my apps. It works on iOS 7 - iOS 8.2.
### UIPresentationController update (iOS 8 only)
A solution using `UIPresentationController` and without iOS 7 hacks can be found in [ios8 branch](https://github.com/pronebird/CustomModalTransition/tree/ios8). It features properly handled appearance events, device orientations support and much less code.
### Caveats
- Controllers will not properly rotate if orientation changed when presented. There is only one exception, if presented controller is a navigation controller, then rotation works fine. This seems to be a UIKit bug on iOS 7 or iOS 8. `UIPresentationController` solves that problem by providing a way to resize controllers on orientation change.
- State restoration is possible but presented VC should restore `transitioningDelegate`, `modalPresentationStyle` and `modalPresentationCapturesStatusBarAppearance`. If you use storyboards then it's easy:```objc
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
[super encodeRestorableStateWithCoder:coder];
[coder encodeInteger:self.modalPresentationStyle forKey:@"modalPresentationStyle"];
[coder encodeInteger:self.modalPresentationCapturesStatusBarAppearance forKey:@"modalPresentationCapturesStatusBarAppearance"];
[coder encodeObject:self.transitioningDelegate forKey:@"transitioningDelegate"];
}
- (void)decodeRestorableStateWithCoder:(NSCoder *)coder {
[super decodeRestorableStateWithCoder:coder];
self.modalPresentationStyle = [coder decodeIntegerForKey:@"modalPresentationStyle"];
self.modalPresentationCapturesStatusBarAppearance = [coder decodeIntegerForKey:@"modalPresentationCapturesStatusBarAppearance"];
self.transitioningDelegate = [coder decodeObjectForKey:@"transitioningDelegate"];
}
```### Blog post
This project is a part of [my blog post](https://coderwall.com/p/njtb0q). However lots of things changed since original blog post was published.
- Unwinding works fine if you fix `segueForUnwindingToViewController` in source navigation controller and create unwind segue using source view controller. Works for both iOS 7 and 8 (see http://stackoverflow.com/a/28607309/351305)
- Resetting views' frames to container bounds before adding them to container helps to solve issues with misplaced navigation bar and rotation issues on iOS 7.