Adds an ability to check current view controller's view state and also to subscribe to view state changes notifications. Also, adds several helpful properties to easily configure some complex behaviors in xibs and storyboards.
Clone the repo and then open Pods Project/ViewState.xcodeproj
ViewState is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ViewState', '~> 2.1'
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding ViewState
as a dependency is as easy as adding it to the dependencies value of your Package.swift
.
ViewState.setupOnce()
somewhere in you code or it won't work. The issue is that SPM doesn't support mixed source code and the framework can't load himself without Objective-C part.
dependencies: [
.package(url: "https://github.com/APUtils/ViewState.git", .upToNextMajor(from: "2.1.0"))
]
- Extends UIViewController with .viewState enum property. Possible cases:
.notLoaded
,.didLoad
,.willAppear
,.didAppear
,.willDisappear
,.didDisappear
. - Every UIViewController starts to send notifications about its state change. Available notifications to observe:
.UIViewControllerWillMoveToParentViewController
,.UIViewControllerViewDidLoad
,.UIViewControllerViewWillAppear
,.UIViewControllerViewDidAppear
,.UIViewControllerViewWillDisappear
,.UIViewControllerViewDidDisappear
. You could checkuserInfo
notification's dictionary for parameters if needed. - Adds
.hideKeyboardOnTouch
@IBInspectable property to hide keyboard on touch outside.
- Adds
.becomeFirstResponderOnViewDidAppear
@IBInspectable property to become first responser onviewDidAppear
.
- Adds
.flashScrollIndicatorsOnViewDidAppear
@IBInspectable property to flash scroll indicators onviewDidAppear
.
See example and test projects for more details.
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.
Anton Plebanovich, anton.plebanovich@gmail.com
ViewState is available under the MIT license. See the LICENSE file for more info.