HPFloatMenu with cool animation for your iOS app, easy setup and use!
pod 'HPFloatMenu'
Copy the HPFloatMenu
folder to your project.
- speed of animation
var animationSpeed: Double = 0.1
- space of each item in the menu
var spacingItem: CGFloat = 15.0
- position of the menu
var position: MenuPosition = .bottomLeft
- overlay color
var colorOverlay: UIColor = UIColor(white: 0, alpha: 0.5)
- radial gradient color
var radialGradientColors: [UIColor]
- configation for item
public struct ItemConfigation {
public var colorTitle: UIColor!
public var colorIcon: UIColor!
public var fontTitle: UIFont!
public var iconSize: CGFloat!
}
- init item with title and icon
init(with title: String, icon: UIImage)
- init item with title, icon and custom configation
init(with title: String, icon: UIImage, config: ItemConfigation)
- init item with title and configation
init(with title: String, config: ItemConfigation)
func floatMenuDidOpen(_ menu: FloatMenuView)
func floatMenuDidClose(_ menu: FloatMenuView)
func floatMenuDidSelectItem(_ menu: FloatMenuView, at index: Int)
Add import HPFloatMenu
in your file
lazy var floatMenuView: FloatMenuView = {
let view = FloatMenuView(frame: .zero)
view.delegate = self
return view
}()
func setDefaultItems() {
let group = FloatMenuItem(with: "Group", config: ItemConfigation(colorIcon: UIColor(hexString: "#CFCFCF")!))
self.floatMenuView.addItem(group)
let watch = FloatMenuItem(with: "Watch", config: ItemConfigation(colorIcon: UIColor(hexString: "#969696")!))
self.floatMenuView.addItem(watch)
let settings = FloatMenuItem(with: "Settings", config: ItemConfigation(colorIcon: UIColor(hexString: "#6D6C6C")!))
self.floatMenuView.addItem(settings)
}
override func viewDidLoad() {
super.viewDidLoad()
self.setDefaultItems()
self.floatMenuView.radialGradientColors = [UIColor(hexString: "#2E2E2E")!.withAlphaComponent(0.9), UIColor(hexString: "#383838")!]
}
@objc private func showMenu(_ sender: Any) {
self.floatMenuView.showMenu(at: sender as! UIButton)
}
extension ViewController: FloatMenuDelegate {
func floatMenuDidOpen(_ menu: FloatMenuView) {
print("FLoat menu did open\n")
}
func floatMenuDidClose(_ menu: FloatMenuView) {
print("Float menu did close\n")
}
func floatMenuDidSelectItem(_ menu: FloatMenuView, at index: Int) {
print("Did select item at index \(index)\n")
menu.dimissItems()
}
}
Swift 5.0
iOS 9.0+
Forks, patches and other feedback are welcome.
HPFloatMenu is available under the MIT license. See the LICENSE file for more info.