TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2017 |
Maintained by Igor Kislyuk.
Framework is for basic modal viewcontroller transitions with human syntax. Special developed for ObjC users
This done with following example
yourViewController.
presentTransition(BCTTransitionFlip).
fromDirection(BCTDirectionTop).
dismissTransition(BCTTransitionPopRadial).
popTo(self.testButton).
withDuration(0.45f);
To integrate Bacteria into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
pod 'Bacteria'
end
Then, run the following command:
$ pod install
Any instruction should be applied to presented controller. You can get it two ways:
//get controller
BCTPresentedViewController *presented = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([BCTPresentedViewController class])];
//bacteria configuration
presented.
presentTransition(BCTTransitionSafari).
dismissTransition(BCTTransitionFlatParallel).
toDirection(BCTDirectionTop).
withDuration(1.45f);
[self presentViewController:presented animated:YES completion:nil];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//get presented controller
BCTPresentedViewController *presented = segue.destinationViewController;
//bacteria configuration
presented.
presentTransition(BCTTransitionFlip).
fromDirection(BCTDirectionTop).
dismissTransition(BCTTransitionPopRadial).
popTo(self.testButton).
withDuration(0.45f);
}
There is only one required method to call. It's withDuration
, because of assigning factory as transition delegate under cover. To help figure out, for which controller you will apply your settings, library use several basic keywords, like: present is used for controller that will be shown, dismiss is used for controller which that be hidden, from is used for controller settings that will be shown, to is used for controller settings that will be hidden
withDuration(XXX)
- use this to specify duration for transition. XXX - float value in seconds. Applied both for present and dismiss transition
presentTransition(XXX)
- use this to specify transition type for presented controller. XXX is one of BCTTransitionType values.
dismissTransition(XXX)
- use this to specify transition for controller, when it will be dismissing. XXX is one of BCTTransitionType values.
fromDirection(XXX)
- use this to specify transition direction for presented controller.
toDirection(XXX)
- use this to specify transition direction, when it will be dismissing.
..* Both for 4 & 5: It works only with BCTTransitionFlatParallel, BCTTransitionFlatCover, BCTTransitionFlip (restricted to first 4 types). XXX is one of BCTDirectionType.
popFrom(XXX)
& popTo(XXX)
- use this to pass view which will be anchor for pop animation. (NOTE: ONLY pop transitions)
fromScale(XXX, YYY)
& toScale(XXX, YYY)
- use this to determine initial or final scale for controller. XXX & YYY measure in units. Range from 0 to 1. (NOTE: ONLY flat transitions)
fromPoint(XXX)
& toPoint(XXX)
- use this to specify direct point from controller starts presentation / dismissal. Possibly unused, and should be discussed for removal in future versions. XXX is point.
Bacteria declares several enum types for configuration.
BCTTransitionType
- main enum which declares different transition types. There are:
BCTTransitionFlatParallel
- default one. If you need move your controllers simultaneously, use it.BCTTransitionFlatCover
- similar to previous, but original controller 'stands still'.BCTTransitionFlip
- basic flip transition like default one, extended for all 4 sides.BCTTransitionSafari
- transition's similar to safari-tab with no-customisation. BCTTransitionPopRadial
- pop, when controller appears/disappears from dot in center of view.BCTTransitionPopLinear
- similar to previous, but uses rect with rounded corners instead of center dot.BCTDirectionType
- enum for determine direction for transitions.(NOTE: ONLY for Flat, FlatCover; for Flip transitions you can use only first 4 sides. Others will be converted to first 4)
BCTDirectionTop
- top sied.BCTDirectionLeft
- left side.BCTDirectionBottom
- bottom side.BCTDirectionRight
- right side.BCTDirectionTopLeft
- top-left corner.BCTDirectionBottomLeft
- bottom-left corner.BCTDirectionBottomRight
- bottom-right corner.BCTDirectionTopRight
- top-right corner. //bacteria configuration
presented.
presentTransition(BCTTransitionFlatCover).
fromDirection(BCTDirectionBottomLeft).
fromScale(0.5, 0.5).
dismissTransition(BCTTransitionFlip).
toDirection(BCTDirectionBottom).
withDuration(0.45f);
to receive:
//bacteria configuration
presented.
presentTransition(BCTTransitionSafari).
withDuration(0.45f);
to receive:
//bacteria configuration
presented.
presentTransition(BCTTransitionSafari).
withDuration(0.45f);
to receive:
addSubview:
Bacteria initially stands for Beautiful Animation Controller Transition. After some time it was renamed to Bacteria, for short and convenience. In other meaning, it can stands for Basic Controller Transitions.
MIT License. See LICENSE file for details.