Skip to content

Latest commit

 

History

History
96 lines (74 loc) · 3.19 KB

README.md

File metadata and controls

96 lines (74 loc) · 3.19 KB

JJFloatingActionButton

Floating Action Button for iOS

Swift 4.0 Version License Platform Build Status codecov Contributions Welcome

Preview

Preview

Requirements

  • iOS 9.0+
  • Swift 4.0+
  • Xcode 9

Installation

CocoaPods

JJFloatingActionButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'JJFloatingActionButton'

Usage

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.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -16).isActive = true
actionButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16).isActive = true

Configuration

var buttonColor: UIColor
var defaultButtonImage: UIImage?
var buttonImageColor: UIColor
var shadowColor: UIColor
var shadowOffset: CGSize
var shadowOpacity: Float
var shadowRadius: CGFloat
var overlayColor: UIColor
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
var interItemSpacing: CGFloat
var rotationAngle: 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, clone the repo, and run pod install from the Example directory first.

Author

Jochen Pfeiffer, [email protected]

License

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