Skip to content

jack45j/Toppon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toppon

A lightweight Scroll-To button for iOS UIScrollView, UITabelView, UITextView. Toppon is a subclass of UIButton. Its not only a Scroll-To button but a fully customizable UIButton.

Preview

Features

  • Lightweight
  • Present with different animations.
  • Multiple display modes.
  • Set whatever positions you want.
  • Customizable button icon.

Installation


CocoaPods

For Swift 4.2 or greater

pod 'Toppon'
Manual

Simply copy files in sources folder into your project.

How to use


Toppon used a builder to initialize itself and using Fluent Interface API to configure You can create a Toppon button like this.

let toppon = Toppon() // or @IBOutlet weak var toppon: Toppon! 
toppon.builder
	.bind(to: scrollview, distance: 100) // Always need to bind Toppon with a UIScrollView.
	.scrollMode(.top)
	.presentMode(.pop)
	.setImage(UIImage(named: "ScrollToBottom")!)
	.build() // Must call this method to apply configuration to Toppon.

Configuration methods

func bind(to scrollView: UIScrollView, distance: CGFloat = 50)
func debug(_ enable: Bool = true)
func scrollMode(_ mode: T.ScrollMode)
func presentMode(_ mode: Toppon.PresentMode)
func setBackground(image: UIImage?, for state: UIControl.State = .normal)
func setImage(_ image: UIImage?, for state: UIControl.State = .normal)
func setActions(didPressed: @escaping (() -> Void), didShow: @escaping (() -> Void), didDismiss: @escaping (() -> Void))

License

Toppon is released under the MIT license. See LICENSE for details.

Author

This project is still work in progress. Feel free to contact me. Benson Lin

What features are going to release.

  1. More animation styles.
  2. Optimize methods and animations
  3. Add a Label above/under Toppon button