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

#swift #uicomponents
YOU MIGHT ALSO LIKE...
SwiftSpeech

Recognize your user's voice elegantly without having to figure out authorization and audio engines. SwiftSpeech Examples Features Installation Getting Started ...

SwiftUIValueSlider

Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 14.0 Installation ...

Sliders

Sliders is a compilation of all my stylable drag based SwiftUI components. It provides a variety of unique controls as well ...

SlidingRuler

SlidingRuler is a Swift package containing a SwiftUI control that acts like an linear infinite slider or a finite, more precise ...

Skeletonui

SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading animations. Get rid of loading screens or spinners and ...