KKFloatingActionButton is very customizable, Material Design-like menu, inspried by the Inbox app made by Google.
To run the example project, clone the repo, and run pod install. Open the .xcworkspace, change the build target to 'Example', and build and run.
iOS 8+ Swift 1.2
KKFloatingActionButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'KKFloatingActionButton', '~> 0.1.0'Refer to the example project for more guidance.
- Add the import statement to your view controller.
import KKFloatingActionButton- Create a UIView(prefrably a perfect square) in IB and assign the custom class to
KKFloatingMaterialButton, then connect it to an outlet in your view controller:
@IBOutlet weak var menuButton: KKFloatingMaterialButton!(Note: This could be done programatically, I just prefer to use IB.)
- Conform to the
KKFloatingMaterialButtonDataSourceandKKFloatingMaterialButtonDelegate
The control contains a customTableViewCell: (UINib, String) property that contains a UINib of the cell to be displayed in the menu, and a String which is the reuseIdentifier to be used for the cell. Set this property with your own custom UITableViewCell. The project does not use a deafult cell, you must provide a custom one. Refer to Example project.
-
Create the custom
UITableViewCellto be used in the menu. Be sure to callconfigureCellForKKFloatingActionButtonMenu()inside the cell'sawakeFromNib()method, otherwise the cells will appear upside down. -
Inside your view controllers
viewDidLoad()call theconfigureViews()method on theKKFloatingMaterialButtonBEFORE customizing.
// Inside viewDidLoad()
menuButton.configureViews() // Call this first
menuButton.dataSource = self
menuButton.delegate = self
// Continue customizing....Here are some of the customization points of the control:
customTableViewCell: (UINib, String)- a tuple to hold a custom table view cell .xib and the reuse identifier associated with it. The must be set with your own customUITableViewCell.buttonShadowColor: UIColor?- The color of the button's shadow.buttonShadowOpacity: CGFloat?- The opacity of the button's shadow. Kept between 0 and 1.buttonBgColor: UIColor?- The background color of the button.menuBgColor: UIColor?- The background color of the overlay that appears when the menu is presented.menuBgOpacity: CGFloat- The opacity of the overlay that appears when the menu is presented.rotatingImage: UIImage?- The image that rotates when the menu is presented. Displayed half the size of the button, aligned with the button's center.imageRotationAngle: CGFloat- The angle to rotate the rotatingImage when the menu is presented.rippleColor: UIColor?- The color of the ripple animation that occurs when the button is toched.ripplePercent: Float- How far the ripple animation when ripple outwards.rippleLocation: MKRippleLocation- The start location of the ripple animation. Refer to MaterialKit documentation https://github.com/nghialv/MaterialKit.
KKFloatingActionButton is available under the MIT license. See the LICENSE file for more info.
- Material Kit - https://github.com/nghialv/MaterialKit
- VCFloatingActionButton - https://github.com/gizmoboy7/VCFloatingActionButton
