Skip to content

Latest commit

 

History

History
151 lines (103 loc) · 4.8 KB

README.md

File metadata and controls

151 lines (103 loc) · 4.8 KB

JJFloatingActionButton

Floating Action Button for iOS

Swift 4.0 Version License Platform Build Status codecov Documentation Contributions Welcome

PreviewFeaturesRequirementsInstallationUsageAuthorLicense

Preview

Preview

Features

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

Requirements

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4.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, '11.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

Configuration

Button appearance and behavior can be customized:

var buttonColor: UIColor
var defaultButtonImage: UIImage?
var openButtonImage: UIImage?
var buttonImageColor: UIColor
var shadowColor: UIColor
var shadowOffset: CGSize
var shadowOpacity: Float
var shadowRadius: CGFloat

var interItemSpacing: CGFloat
var rotationAngle: CGFloat

var itemTitleFont: UIFont
var itemButtonColor: UIColor
var itemImageColor: UIColor
var itemTitleColor: UIColor
var itemShadowColor: UIColor
var itemShadowOffset: CGSize
var itemShadowOpacity: Float
var itemShadowRadius: CGFloat
var itemSizeRatio: CGFloat

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.