https://github.com/quanghoang0101/hpfloatmenu
A library for floating menu, user can easy custom the menu with icons and text.
https://github.com/quanghoang0101/hpfloatmenu
custom-menus float float-menu floating floating-action-button floatingmenu ios ios-swift ios-uiview menu menu-ios swift
Last synced: about 1 month ago
JSON representation
A library for floating menu, user can easy custom the menu with icons and text.
- Host: GitHub
- URL: https://github.com/quanghoang0101/hpfloatmenu
- Owner: quanghoang0101
- License: mit
- Created: 2019-04-22T14:05:53.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-06T16:20:03.000Z (almost 6 years ago)
- Last Synced: 2025-04-09T16:06:46.337Z (about 1 month ago)
- Topics: custom-menus, float, float-menu, floating, floating-action-button, floatingmenu, ios, ios-swift, ios-uiview, menu, menu-ios, swift
- Language: Swift
- Homepage:
- Size: 1.17 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HPFloatMenu
[](https://developer.apple.com/iphone/index.action)
[](https://developer.apple.com/swift)
[](https://cocoapods.org/pods/HPFloatMenu)
[](http://mit-license.org)
[](https://github.com/quanghoang0101/HPFloatMenu/issues?state=open)

[](https://codecov.io/gh/quanghoang0101/HPFloatMenu)HPFloatMenu with cool animation for your iOS app, easy setup and use!

# Installation
#### CocoaPods
```
pod 'HPFloatMenu'
```
#### Manually
Copy the `HPFloatMenu` folder to your project.## Customization
### HPFloatMenuView Customizable
* speed of animation
```Swift
var animationSpeed: Double = 0.1
```
* space of each item in the menu
```Swift
var spacingItem: CGFloat = 15.0
```
* position of the menu
```Swift
var position: MenuPosition = .bottomLeft
```
* overlay color
```Swift
var colorOverlay: UIColor = UIColor(white: 0, alpha: 0.5)
```
* radial gradient color
```Swift
var radialGradientColors: [UIColor]
```
### FloatMenuItem Customizable
* configation for item
```Swift
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
```Swift
init(with title: String, icon: UIImage)
```* init item with title, icon and custom configation
```Swift
init(with title: String, icon: UIImage, config: ItemConfigation)
```* init item with title and configation
```Swift
init(with title: String, config: ItemConfigation)
```
### Monitor the states of menu, you can use `FloatMenuDelegate` use this:
```swift
func floatMenuDidOpen(_ menu: FloatMenuView)
func floatMenuDidClose(_ menu: FloatMenuView)
func floatMenuDidSelectItem(_ menu: FloatMenuView, at index: Int)
```## Usage
### Setup
Add `import HPFloatMenu` in your file```Swift
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()
}
}
```
## Requirements
Swift 5.0iOS 9.0+
## Contributing
Forks, patches and other feedback are welcome.## Creator
### HPFloatMenu
[Quang Hoang](https://github.com/quanghoang0101)[Blog](https://medium.com/@phanquanghoang)
## License
HPFloatMenu is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.