Swiftpack.co - Package - jjochen/JJFloatingActionButton
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

JJFloatingActionButton

Floating Action Button for iOS


Swift 5.0 Version License Platform Build Status codecov Code Climate Documentation Contributions Welcome

FeaturesPreviewRequirementsInstallationUsageAuthorLicense

Features

  • Easy to use ✓
  • Fully customizable ✓
  • Place with auto layout ✓
  • Design in Interface Builder ✓
  • RTL language support ✓
  • Handles Button with single Action ✓
  • Works in Swift and Objective-C Projects ✓
  • Comprehensive Test Coverage ✓
  • Complete Documentation

Preview

Preview Basics Preview Configuration

Preview Circular Preview Single Item

Requirements

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate JJFloatingActionButton into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'JJFloatingActionButton'
end

Then, run the following command:

$ pod install

Manually

If you prefer not to use a dependency manager, you can integrate JJFloatingActionButton into your project manually.

Usage

Quick Start

let actionButton = JJFloatingActionButton()

actionButton.addItem(title: "item 1", image: UIImage(named: "First")?.withRenderingMode(.alwaysTemplate)) { item in
  // do something
}

actionButton.addItem(title: "item 2", image: UIImage(named: "Second")?.withRenderingMode(.alwaysTemplate)) { item in
  // do something
}

actionButton.addItem(title: "item 3", image: nil) { item in
  // do something
}

view.addSubview(actionButton)
actionButton.translatesAutoresizingMaskIntoConstraints = false
actionButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16).isActive = true
actionButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16).isActive = true

// last 4 lines can be replaced with
// actionButton.display(inViewController: self)

Configuration

Button appearance and behavior can be customized:

actionButton.handleSingleActionDirectly = false
actionButton.buttonDiameter = 65
actionButton.overlayView.backgroundColor = UIColor(white: 0, alpha: 0.3)
actionButton.buttonImage = UIImage(named: "Dots")
actionButton.buttonColor = .red
actionButton.buttonImageColor = .white
actionButton.buttonImageSize = CGSize(width: 30, height: 30)

actionButton.buttonAnimationConfiguration = .transition(toImage: UIImage(named: "X"))
actionButton.itemAnimationConfiguration = .slideIn(withInterItemSpacing: 14)

actionButton.layer.shadowColor = UIColor.black.cgColor
actionButton.layer.shadowOffset = CGSize(width: 0, height: 1)
actionButton.layer.shadowOpacity = Float(0.4)
actionButton.layer.shadowRadius = CGFloat(2)

actionButton.itemSizeRatio = CGFloat(0.75)
actionButton.configureDefaultItem { item in
    item.titlePosition = .trailing

    item.titleLabel.font = .boldSystemFont(ofSize: UIFont.systemFontSize)
    item.titleLabel.textColor = .white
    item.buttonColor = .white
    item.buttonImageColor = .red

    item.layer.shadowColor = UIColor.black.cgColor
    item.layer.shadowOffset = CGSize(width: 0, height: 1)
    item.layer.shadowOpacity = Float(0.4)
    item.layer.shadowRadius = CGFloat(2)
}

actionButton.addItem(title: "Balloon", image: UIImage(named: "Baloon")) { item in
    // Do something
}

let item = actionButton.addItem()
item.titleLabel.text = "Owl"
item.imageView.image = UIImage(named: "Owl")
item.buttonColor = .black
item.buttonImageColor = .white
item.buttonImageColor = CGSize(width: 30, height: 30)
item.action = { item in
    // Do something
}

Delegate

optional func floatingActionButtonWillOpen(_ button: JJFloatingActionButton)
optional func floatingActionButtonDidOpen(_ button: JJFloatingActionButton)
optional func floatingActionButtonWillClose(_ button: JJFloatingActionButton)
optional func floatingActionButtonDidClose(_ button: JJFloatingActionButton)

Example

To run the example project, just run the following command:

$ pod try JJFloatingActionButton

Resources

Author

Jochen Pfeiffer https://github.com/jjochen

License

JJFloatingActionButton is available under the MIT license. See the LICENSE file for more info.

Github

link
Stars: 225

Releases

2.5.0 - 2020-04-21T14:59:49

Full Changelog

Implemented enhancements:

  • Spacing Betwens Items #258
  • Create issue templates #257

Fixed bugs:

  • bundle —path is deprecated #247

Merged pull requests:

  • Create issue templates #263
  • Separate spacing between action button and first action item #262 [added]
  • Update dependencies #261
  • Use bundle config to set path for bundler #260
  • Fix access to functions in AnimationConfiguration #259 [fixed]
  • Less restricted filter for release commit messages #253

2.4.0 - 2020-03-20T09:47:22

Full Changelog

Implemented enhancements:

  • CircleCI config could be simplified #249
  • Run 'release new version' task on CircleCI/GitHub #248
  • Automatically close milestone when version is released #246

Merged pull requests:

  • Fix release workflow on CircleCI #251
  • Refactor CircleCI configuration #250
  • Improve release workflow on CircleCI #245

2.3.0 - 2020-03-05T05:46:42

Full Changelog

Implemented enhancements:

  • Add method to remove action item #239

Fixed bugs:

  • Need to remove animation while closing items #223

Merged pull requests:

  • Improve deployment #241
  • Add convenience methods to remove action items from the button #240 [added]
  • Remove related views when button is removed from superview #238 [fixed]

2.2.0 - 2020-03-02T06:16:37

Full Changelog

Implemented enhancements:

  • Leave action items visible #221

Fixed bugs:

  • Code coverage checks not working in pull requests #165

Merged pull requests:

  • Fix changelog generation #235
  • Prevent item selection during closing animation #234 [changed]
  • Allow item selection during opening animation #233 [changed]
  • Fix typos #232
  • Make automatic closing of action button configurable #231 [added]
  • Update dependencies #230
  • Some improvements to test suite #229
  • Support for Swift Package Manager #228

2.1.0 - 2019-09-12T10:52:23

Full Changelog

Implemented enhancements:

  • Add image size property to action items #203

Merged pull requests:

  • Support dark mode in example project #217
  • Update configuration example in README and example project #215
  • Make image sizes configurable #213 [added]
  • Fix an issue where special action item configuration would not work #212 [fixed]
  • Update dependencies #210
  • Get ready for Xcode 11/iOS 13 #209

2.0.0 - 2019-04-09T10:00:18

Full Changelog

Implemented enhancements:

  • Swift 5 support #197

Merged pull requests:

1.2.0 - 2019-02-08T13:39:54

Full Changelog

Implemented enhancements:

  • Upgrade to circleci 2.1 #183

Fixed bugs:

  • Button size changes with rotation/transition #191

Merged pull requests:

  • Add swiftformat configuration file #194
  • Prevent images to change button/item size #193 [changed] [fixed]
  • Update project dependencies #189
  • Make default button size configurable #188 [added]
  • Add license title to LICENSE file #187
  • Upgrade circleci config to version 2.1 #185

1.1.0 - 2019-01-13T15:08:43

Full Changelog

Implemented enhancements:

  • Add convenience initializer for single item button #138

Merged pull requests:

  • Add convenience initializer for floating action button with single item #178 [added]
  • Disable redundant_objc_attribute rule in swiftlint configuration #177

1.0.0 - 2018-11-29T13:14:12

Full Changelog

Implemented enhancements:

  • Swift 4.2 support #159

Fixed bugs:

  • Item tap area overlaps in circular pop up style #170

Merged pull requests:

  • Update dependencies #173
  • Update README #172
  • Fix item layout in circular pop up style #171 [fixed]
  • Add convenience method to action item that calls it's action #169 [added]
  • Update tests for iOS 12.1 and new devices #163
  • Migrate to swift 4.2 #161 [changed]

0.10.0 - 2018-09-17T12:28:37

Full Changelog

Implemented enhancements:

  • Make spacing between the titleLabel and circleView configurable #154

Merged pull requests:

  • Update dependencies #156
  • Make title spacing configurable #155 [added]
  • Add example for downward animation #153
  • Add example on how to change size of action button #152
  • Update dependencies and circleci configuration #148

0.9.2 - 2018-06-18T09:53:55

Full Changelog

Implemented enhancements:

  • View inset for bottom and trailing separately #144

Merged pull requests:

  • Fix circle ci checks #146
  • Separate bottom and trailing inset in layout category #145 [added]

0.9.1 - 2018-03-01T15:23:58

Full Changelog

Merged pull requests:

  • Recreate preview gifs on iPhone 8 #139

0.9.0 - 2018-03-01T12:13:29

Full Changelog

Implemented enhancements:

  • Make item title position configurable #122
  • Add more opening styles #87

Merged pull requests:

  • Add App Icon to example project #136
  • Improve configurability of animations #134 [added] [changed]
  • Add codeclimate configuration #133
  • Configure swift version in pod spec #131
  • Make position of action item title configurable #130 [added]
  • Update dependencies #129
  • Revert default color for item title and item circle to white #126 [changed]

0.8.0 - 2018-01-22T13:57:43

Full Changelog

Implemented enhancements:

  • remove shadow properties and handle directly #118
  • Configure default item with public function #117
  • Split preview gifs #114
  • Use swift enum (handle objc in extension) #59

Merged pull requests:

0.7.2 - 2018-01-11T11:04:44

Full Changelog

Fixed bugs:

  • Placement methods not accessible from objective-c #111

Merged pull requests:

  • Rename placement methods to fix objc issues #112 [changed]
  • Create release pull requests with octokit.rb #110

0.7.1 - 2018-01-09T09:08:42

Full Changelog

Merged pull requests:

  • Rename methods for placing button in view or view controller #107 [changed]
  • Improved example #106
  • Add task for updating releases on GitHub #104
  • Add rake task for creating releases on GitHub #103

0.7.0 - 2018-01-08T12:02:23

Full Changelog

Implemented enhancements:

  • Add test for documentation coverage #98
  • Handle actions instantly upon tap #71
  • Handle placement in view controller #57
  • Add tests for delegate calls #42
  • Support UIAppearance #30

Fixed bugs:

  • Documentation for placement missing #94

Merged pull requests:

  • Add test for documentation coverage #101
  • Handle new github labels in change log #100
  • Fix exception when loading button from xib during tests #99
  • Add documentation and improve tests for button placement #97
  • User Xcode 9.1 on CircleCI #96
  • Improve labels in change log #93
  • Extension for placing action button in view or view controller #92 [added]
  • Use xcpretty in CI builds #91
  • Better support for UIAppearance #90 [updated]
  • Add delegate calls to example #89
  • Handle tasks with rake #88
  • Handle action directly when item is tapped #86 [changed]
  • Add tests for delegate calls #85

0.6.4 - 2018-01-03T09:46:41

Full Changelog

Merged pull requests:

  • Update readme and changelog #83

0.6.3 - 2018-01-02T22:48:43

Full Changelog

Merged pull requests:

  • Define file header template (MIT License) #81
  • Remove author from pull requests in changelog #80
  • Add screenshot and documentation url to podspec #79
  • Explicit anchors in readme #78

0.6.2 - 2018-01-02T20:25:57

Full Changelog

Merged pull requests:

  • Push podspec to trunk when version is tagged #76
  • Add more items to feature list in readme #75

0.6.0 - 2018-01-01T19:49:55

Full Changelog

Implemented enhancements:

  • Remove unnecessary properties #63
  • Document functions/properties from superclasses #61
  • Improve README #60
  • Check RTL Languages #55
  • Handle hidden action items #36
  • Support Swift Package Manager #27
  • Draw default button image #17

Merged pull requests:

  • Add license to each file #69
  • Improve Readme #68
  • Improve documentation #67
  • Investigate swift package manager support #66
  • Draw assets (remove assets bundle) #65 [updated]
  • Expose overlay view as read only property #64 [added]
  • RTL language support #58 [added]
  • Add documentation for github pages #54
  • Improve release script #53
  • Handle hidden items #52 [added]
  • Handle open/close animations in separate classes #51 [updated]
  • Continuous integration improvements #50

0.6.1 - 2018-01-01T19:49:38

Full Changelog

Implemented enhancements:

  • Update preview #72

Merged pull requests:

  • Update preview #73

0.5.0 - 2017-12-21T19:25:46

Full Changelog

Implemented enhancements:

  • Check if imageView and openImageView can be merged into one #45
  • Make single action configurable #39
  • Improve Documentation #4

Merged pull requests:

  • Add documentation #47
  • Add image transition when button opens/closes #46 [updated]
  • Make single action handling configurable #44 [added]
  • Add swiftlint to CircleCi workflow #43

0.4.0 - 2017-12-15T11:49:49

Full Changelog

Implemented enhancements:

  • Animate change to open button image #35
  • Make properties IB designable #3
  • Improve configurability of action items #1

Merged pull requests:

0.3.1 - 2017-11-30T09:39:15

Full Changelog

Fixed bugs:

  • wrong item position during first open animation #23

Merged pull requests:

  • Hotfix: wrong item position during first opening animation #24 [fixed]

0.3.0 - 2017-11-30T08:37:10

Full Changelog

Implemented enhancements:

  • Button should have configurable image for open state #18

Merged pull requests:

  • Add optional open button image #21 [added]
  • Improve preview in readme #20
  • Handle touches with UIControl #19 [updated]
  • Improve test coverage #16

0.2.1 - 2017-11-30T08:36:34

Full Changelog

Fixed bugs:

  • Snapshot tests not working correctly #33

0.2.0 - 2017-11-16T19:52:20

Full Changelog

Implemented enhancements:

  • Improve example #11
  • Improve test coverage #10
  • Restructure project folder #8

Merged pull requests:

  • Improve travis configuration #15
  • Add codecov configuration #14
  • Improve example #13
  • Improve test coverage #12
  • Restructure project folder #9

0.1.2 - 2017-11-08T14:50:05

Full Changelog

Implemented enhancements:

  • remove SnapKit dependency #2

Merged pull requests:

0.1.1 - 2017-11-06T15:21:39

Full Changelog

  • improve closing animation
  • improve ReadMe
  • bug fixes