JJFloatingActionButton
Floating Action Button for iOS
Features • Preview • Requirements • Installation • Usage • Author • License
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
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 |
You may find interesting
Releases
2.5.0 - 2020-04-21T14:59:49
2.4.0 - 2020-03-20T09:47:22
2.3.0 - 2020-03-05T05:46:42
2.2.0 - 2020-03-02T06:16:37
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
2.0.0 - 2019-04-09T10:00:18
1.2.0 - 2019-02-08T13:39:54
1.1.0 - 2019-01-13T15:08:43
Implemented enhancements:
- Add convenience initializer for single item button #138
Merged pull requests:
1.0.0 - 2018-11-29T13:14:12
0.10.0 - 2018-09-17T12:28:37
Implemented enhancements:
- Make spacing between the titleLabel and circleView configurable #154
Merged pull requests:
0.9.2 - 2018-06-18T09:53:55
0.9.1 - 2018-03-01T15:23:58
0.9.0 - 2018-03-01T12:13:29
Implemented enhancements:
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
0.7.2 - 2018-01-11T11:04:44
0.7.1 - 2018-01-09T09:08:42
0.7.0 - 2018-01-08T12:02:23
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
0.6.3 - 2018-01-02T22:48:43
Merged pull requests:
0.6.2 - 2018-01-02T20:25:57
Merged pull requests:
0.6.0 - 2018-01-01T19:49:55
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
0.5.0 - 2017-12-21T19:25:46
0.4.0 - 2017-12-15T11:49:49
0.3.1 - 2017-11-30T09:39:15
0.3.0 - 2017-11-30T08:37:10
0.2.1 - 2017-11-30T08:36:34
0.2.0 - 2017-11-16T19:52:20
0.1.2 - 2017-11-08T14:50:05
0.1.1 - 2017-11-06T15:21:39
- improve closing animation
- improve ReadMe
- bug fixes