#AAFragmentManager
##Description
AAFragmentManager is a child view manager responsible to add child subviews in UIView, designed for easy switching between child view controllers with animations.
##Demonstration
To run the example project, clone the repo, and run pod install
from the Example directory first.
##Requirements
- iOS 8.0+
- Xcode 8.0+
AAFragmentManager
can be installed using CocoaPods, Carthage, or manually.
##CocoaPods
AAFragmentManager
is available through CocoaPods. To install CocoaPods, run:
$ gem install cocoapods
Then create a Podfile with the following contents:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AAFragmentManager', :git => 'https://github.com/mengheangrat/AAFragmentManager.git'
end
Finally, run the following command to install it:
$ pod install
##Carthage
To install Carthage, run (using Homebrew):
$ brew update
$ brew install carthage
Then add the following line to your Cartfile:
github "EngrAhsanAli/AAFragmentManager"
Then import the library in all files where you use it:
import AAFragmentManager
##Manual Installation
If you prefer not to use either of the above mentioned dependency managers, you can integrate AAFragmentManager
into your project manually by adding the files contained in the Classes folder to your project.
##Create your fragment manager
Create a UIView
and set the class as AAFragmentManager
. Make an IBOutlet
of that view.
@IBOutlet weak var childView: AAFragmentManager!
You need to set all child views identifiers and make a
UIViewController
array to passAAFragmentManager
##Setup your child views
Now create child views (fragments) using single line
childView.setupFragments(arrayVC, defaultIndex: 0)
Note that
defaultIndex
is for first initial child view that will be automatically added by theAAFragmentManager
.defaultIndex
is optional parameter.
##Get any child views controller
You can get any child view controller by accessing it through index
let demoFragment = childView.getFragment(0)
demoFragment.delegate = self // sets for some callback
Note that
getFragment
method can returnnil
if any invalid index passed.
##Switching between child views
You can switch child view controllers using the single line
childView.replaceFragment(index: 1)
Note that replaceFragment has optional parameters
shouldAnimate
,shouldFit
,allowSameFragment
.
Here's the method signature
open func replaceFragment(index: Int, shouldAnimate animate: Bool = true, shouldFit fit: Bool = true, allowSameFragment sameFragment: Bool = false)
By default,
shouldFit
is true such that it will make fragment of same height as its parent view and vice versa.
#Contributions & License
AAFragmentManager
is available under the MIT license. See the LICENSE file for more info.
Pull requests are welcome! The best contributions will consist of substitutions or configurations for classes/methods known to block the main thread during a typical app lifecycle.
I would love to know if you are using AAFragmentManager
in your app, send an email to Engr. Ahsan Ali