Floaty
  • November 8, 2023

Floaty is simple floating action button for iOS. (formerly KCFloatingActionButton)

Why change the name?

  1. Follow the swift naming convention.
  2. KCFloatingActionButton is too long.

Preview


Requirements


  • iOS 10.0+
  • Swift 5.0

Installation


CocoaPods

use_frameworks!
pod ‘Floaty’, ‘~> 4.2.0’

Carthage

 

github “kciter/Floaty”

Swift Package Manager

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”)
]

Manually

To install manually the Floaty in an app, just drag the Floaty/*.swift file into your project.

Usage


Storyboard support

Dependent on the UIWindow.

Floaty.global.button.addItem(title: “Hello, World!”)
Floaty.global.show()

Dependent on the UIViewController

let floaty = Floaty()
floaty.addItem(title: “Hello, World!”)
self.view.addSubview(floaty)

Use icon

let floaty = Floaty()
floaty.addItem(“Hello, World!”, icon: UIImage(named: “icon”)!)
self.view.addSubview(floaty)

Use handler

Swift

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)

Use custom item

let item = FloatyItem()
item.buttonColor = UIColor.blueColor()
item.title = “Custom item”
Floaty.global.button.addItem(item: item)

RTL Support

You can use the rtlMode property to mirror the Floaty Button for rtl languages.

Floaty.global.rtlMode = true

Sticky

You can use the sticky property.

floaty.sticky = true // sticking to parent UIScrollView(also UITableView, UICollectionView)
scrollView.addSubview(floaty)

Friendly Tap

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.

Animation type

Pop Fade Slide Left
Pop animation gif Fade animation gif Slide left animation gif
Slide Up None
Slide up animation gif None animation gif

 

GitHub


View Github

#floatingactionbutton #swift #uicomponents
YOU MIGHT ALSO LIKE...
EEStackLayout

A vertical stackview which takes subviews with different widths and adds them to it's rows with paddings, spacings etc.

AudioManager

AudioManager is a Swift package that provides a modular and easy-to-use interface for implementing audio feedback in your applications. It ...

CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...