Make It Your Own
Pre-requisites
Customization should only be applied before presenting the menu, and assume that you already have either one of the following:
- a
PopMenuViewController
variable called ->menu
- a
PopMenuManager
variable called ->manager
default: true
Dismiss On SelectionIf you don't want the menu to auto-dismiss once a selection has been performed, you can change the property:
menu.shouldDismissOnSelection = false
// ======= or =======
manager.popMenuShouldDismissOnSelection = false
default: .dimmed(color: .black, opacity: 0.4)
Background stylesThere are mainly 3 types of background styles:
- Blurred (dark, light & extra Light)
- Dimmed (color & opacity)
- None
Simply set the popMenuBackgroundStyle
on the appearance property using .
notation:
menu.appearance.popMenuBackgroundStyle = .blurred(.dark)
menu.appearance.popMenuBackgroundStyle = .blurred(.light)
menu.appearance.popMenuBackgroundStyle = .blurred(.extralight)
menu.appearance.popMenuBackgroundStyle = .dimmed(color: .white, opacity: 0.6)
menu.appearance.popMenuBackgroundStyle = .none()
// ======= or =======
manager.popMenuAppearance.popMenuBackgroundStyle = .blurred(.dark)
default: white
Action ColorTo bulk set action colors is simple and straightforward:
menu.appearance.popMenuColor.actionColor = .tint(.green) // or use Color Literals if you're using Xcode 9
// ======= or =======
manager.popMenuAppearance.popMenuColor.actionColor = .tint(.green) // or use Color Literals if you're using Xcode 9
To set each action with different color, you'll have to specify in the color
parameter initializer of action PopMenuDefaultAction
:
let actions = [
PopMenuDefaultAction(title: "Some Title", image: UIImage(named: "blah"), color: .gray),
PopMenuDefaultAction(title: "Another Title", image: UIImage(named: "icon"), color: .yellow)
]
default: flat dark gradient
Background Color(s)There are 2 types of background colors:
- Solid fill (one color)
- Gradient fill (two colors)
To set the background color(s) of the menu:
menu.appearance.popMenuColor.backgroundColor = .solid(fill: .gray) // A solid gray background color
menu.appearance.popMenuColor.backgroundColor = .gradient(fill: .yellow, .pink) // A gradient from yellow to pink
// ======= or =======
manager.popMenuAppearance.popMenuColor.backgroundColor = ...
default: .systemFont(ofSize: 16, weight: .semiBold)
Action FontTo set the font of all actions:
menu.appearance.popMenuFont = UIFont(name: "AvenirNext-DemiBold", size: 14)!
menu.appearance.popMenuFont = .systemFont(ofSize: 15, weight: .bold)
// ======= or =======
manager.popMenuAppearance.popMenuFont = ...
default: 24
Corner RadiusTo set corner radius of the menu container:
menu.appearance.popMenuCornerRadius = 10
// ======= or =======
manager.popMenuAppearance.popMenuCornerRadius = 10
default: 50
Action HeightTo set height of each action:
menu.appearance.popMenuActionHeight = 65
// ======= or =======
manager.popMenuAppearance.popMenuActionHeight = 65
default: none
Action Item SeparatorTo set the action item separator:
menu.appearance.popMenuItemSeparator = .none()
menu.appearance.popMenuItemSeparator = .fill() // Default height of 0.5, white color with 0.5 opacity
menu.appearance.popMenuItemSeparator = .fill(.yellow, height: 1) // Or set it yourself
// ======= or =======
manager.popMenuAppearance.popMenuItemSeparator = ...
default: .alwaysTemplate
Action Image Rendering ModeTo set the action item image rendering mode:
let action = PopMenuDefaultAction(title: "Some Title", image: UIImage(named: "blah"), color: .gray)
action.imageRenderingMode = .alwaysOriginal
default: 27
Action Image SizingTo set the action item image sizing:
let action = PopMenuDefaultAction(title: "Some Title", image: UIImage(named: "blah"), color: .gray)
action.iconWidthHeight = 45
Scrollable when actions are too many
To set the scrolling properties:
menu.appearance.popMenuActionCountForScrollable = 10 // default 6
menu.appearance.popMenuScrollIndicatorHidden = true // default false
menu.appearance.popMenuScrollIndicatorStyle = .black // default .white
// ======= or =======
manager.popMenuAppearance.popMenuActionCountForScrollable = ... // same as above
default: automatic detection based on background color
Status Bar StyleIf you don't want PopMenu
to use automatic detection to set status bar style, you can override it:
menu.appearance.popMenuStatusBarStyle = .default
// ======= or =======
manager.popMenuAppearance.popMenuStatusBarStyle = .default
Missing Customization?
If there's any missing customization that you'd want PopMenu
to have, feel free to open an issue in the official GitHub repository.