- December 17, 2024
- Mins Read
Floaty is simple floating action button for iOS. (formerly KCFloatingActionButton)
Why change the name?
KCFloatingActionButton
is too long.
use_frameworks!
pod ‘Floaty’, ‘~> 4.2.0’
github “kciter/Floaty”
Once you have your Swift package set up, adding Floaty as a dependency is as easy as adding it to the dependencies value of your Package.swift
.
dependencies: [
.package(url: “https://github.com/kciter/Floaty.git”, from: “4.2.1”)
]
To install manually the Floaty in an app, just drag the Floaty/*.swift
file into your project.
Floaty.global.button.addItem(title: “Hello, World!”)
Floaty.global.show()
let floaty = Floaty()
floaty.addItem(title: “Hello, World!”)
self.view.addSubview(floaty)
let floaty = Floaty()
floaty.addItem(“Hello, World!”, icon: UIImage(named: “icon”)!)
self.view.addSubview(floaty)
let floaty = Floaty()
floaty.addItem(“I got a handler”, icon: UIImage(named: “icon”)!, handler: { item in
let alert = UIAlertController(title: “Hey”, message: “I’m hungry…”, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: “Me too”, style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
floaty.close()
})
self.view.addSubview(floaty)
let item = FloatyItem()
item.buttonColor = UIColor.blueColor()
item.title = “Custom item”
Floaty.global.button.addItem(item: item)
You can use the rtlMode
property to mirror the Floaty Button for rtl languages.
Floaty.global.rtlMode = true
You can use the sticky
property.
floaty.sticky = true // sticking to parent UIScrollView(also UITableView, UICollectionView)
scrollView.addSubview(floaty)
You can use the friendlyTap
property.
fab.friendlyTap = true
scrollView.addSubview(fab)
With the default location of the frame, the button is now tappable until the right and rightbottom of the screen. This prevents tapping behind it by accident.
Pop | Fade | Slide Left |
---|---|---|
Slide Up | None | |
A vertical stackview which takes subviews with different widths and adds them to it's rows with paddings, spacings etc.
AudioManager is a Swift package that provides a modular and easy-to-use interface for implementing audio feedback in your applications. It ...