PullToReach is a simple drag-and-drop solution for implementing the pull-to-reach functionality seen in the music app Soor by Tanmay. This allows your users with big phones to reach the content on the top of the display easily.
Getting started is as easy as conforming your ViewController to the PullToReach
protocol and activating the functionality by calling the activatePullToReach
function.
class TeamMembersViewController: UITableViewController, PullToReach {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.rightBarButtonItems = [
addBarButtonItem,
refreshBarButtonItem
]
self.activatePullToReach(on: navigationItem)
}
...
If your ViewController is contained in an UINavigationController
you can activate pull-to-reach on all UIBarButtonItems
. Selecting an item using pull-to-reach will call the same action as the normal UIBarButtonItem action so there is nothing more for you to be done.
If you want to change the highlight color, you can specify it when activating pull-to-reach.
self.activatePullToReach(on: navigationItem, highlightColor: .red)
By overriding the applyStyle
function you can define completely custom style. All the changes between states will be animated by default.
class ScalingButton: UIButton {
override func applyStyle(isHighlighted: Bool, highlightColor: UIColor) {
let scale: CGFloat = isHighlighted ? 1.5 : 1.0
transform = CGAffineTransform(translationX: scale, y: scale)
}
}
Pull-To-Reach can not only be activated for the navigation items, but also for every UIControl
independently from its position or functionality. This can be very helpful when you have non-standard views with your own controls. To define your style, you can override applyStyle
as seen above.
To integrate PullToReach into your Xcode project using CocoaPods, add this to your Podfile
:
pod 'PullToReach'
To run the example project, clone the repo, and run pod install
from the Example directory first.
If you prefer not to use any of the dependency managers, you can integrate PullToReach into your project manually, by downloading the source code and placing the files on your project directory.
This framework is created with β€οΈ by QuickBird Studios.
Open an issue if you need help, if you found a bug, or if you want to discuss a feature request.
Open a PR if you want to make changes to PullToReach.
PullToReach is released under an MIT license. See License.md for more information