• Stars
    star
    113
  • Rank 309,323 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The most customizable menu for macOS apps.

Menu

Swift macOS License: MIT

Fully customizable macOS drop-down menu. It includes 30 settings you can play with.

Requirements

  • Xcode 11+
  • macOS 10.12+
  • Swift 5.0 and higher

Installation

Since this is a Swift Package, the installation process is pretty stright forward.

Manual way

Update your Package.swift dependencies:

dependencies: [
    .package(url: "https://github.com/iSapozhnik/Menu", from: "1.10.1")
]

Via Xcode:

  1. Go to File -> Swift Packages -> Add Package Dependency.
  2. Put GitHub URL https://github.com/iSapozhnik/Menu and click Next
  3. Select the latest version
  4. Click Finish

What can be customized? Everything!

public protocol Configuration {
    var titleBottomSpace: CGFloat                           { get }
    var titleFont: NSFont?                                  { get }
    var titleColor: NSColor                                 { get }
    var backgroundColor: NSColor                            { get }
    var cornerRadius: CGFloat                               { get }
    var hasShadow: Bool                                     { get }
    var appearsBelowSender: Bool                            { get }
    var presentingOffset: CGFloat                           { get }
    var animationDuration: TimeInterval                     { get }
    var contentEdgeInsets: NSEdgeInsets                     { get }
    var maximumContentHeight: CGFloat?                      { get }
    var separatorColor: NSColor                             { get }
    var separatorThickness: CGFloat                         { get }
    var separatorHorizontalPadding: Padding.Horizontal      { get }
    var separatorVerticlaPadding: Padding.Vertical          { get }
    var rememberSelection: Bool                             { get }
    var textAlignment: Alignment                            { get }
    var iconAlignment: Alignment                            { get }
    var menuItemFont: NSFont?                               { get }
    var menuItemHeight: CGFloat                             { get }
    var menuItemHoverBackgroundColor: NSColor               { get }
    var menuItemTextColor: NSColor                          { get }
    var menuItemHoverTextColor: NSColor                     { get }
    var menuItemCheckmarkColor: NSColor                     { get }
    var menuItemHoverCheckmarkColor: NSColor                { get }
    var menuItemCheckmarkHeight: CGFloat                    { get }
    var menuItemCheckmarkThikness: CGFloat                  { get }
    var menuItemHorizontalSpacing: CGFloat                  { get }
    var menuItemImageHeight: CGFloat?                       { get }
    var menuItemImageTintColor: NSColor?                    { get }
    var menuItemHoverImageTintColor: NSColor?               { get }
    var menuItemHoverAnimationDuration: TimeInterval        { get }
}

How to use

import Cocoa
import Menu

class ViewController: NSViewController {
    private let myMenu = Menu(with: "Select a search engine:")

    @IBOutlet var showMenuButton: NSButton!

    override func viewDidLoad() {
        super.viewDidLoad()

        let bing = MenuItem("Bing search", image: Icn.bing.image, action: { [weak self] in
            self?.showMenuButton.title = "Bing"
        })
        let item = MenuItem("DuckDuckGo search", image: Icn.duck.image, action: { [weak self] in
            self?.showMenuButton.title = "DuckDuckGo"
        })
        let google = MenuItem("Google search", image: Icn.google.image, action: { [weak self] in
            self?.showMenuButton.title = "Google"
        })
        let longText = MenuItem("Some very-very-very long text with no icon", action: { [weak self] in
            self?.showMenuButton.title = "Some very long text"
        })
        let emojiItem = MenuItem("Emojis are here ๐Ÿ˜Ž๐Ÿš€", action: { [weak self] in
            self?.showMenuButton.title = "Emojis are here ๐Ÿ˜Ž๐Ÿš€"
        })
        let exit = MenuItem("Exit", image: Icn.exit.image, action: {
            NSApplication.shared.terminate(nil)
        })
        let separator = MenuItem.separator()
        let menuItems = [
            bing,
            item,
            google,
            separator,
            longText,
            emojiItem,
            separator,
            exit
        ]

        myMenu.addItems(menuItems)
    }

    @IBAction func didClickButton(_ sender: NSButton) {
        myMenu.show(from: sender)
    }
}

Examples

In this section I've collected some examples of what can be i,plemented do using Menu control. On the left side some random example from Dribbble and on the right side my implementation.

Dribbble Menu Code
link
link
code

Credits

Created and maintained by @iSapozhnik.

License

Released under the MIT License. See LICENSE for details.

Copyright ยฉ 2020-present Sapozhnik Ivan.

More Repositories

1

Haptico

Haptico ๐Ÿ“ณ - easy to use haptic feedback generator with pattern-play support
Swift
484
star
2

NavigationMenu

[DEPRECATED] Objective-C component that adds menu to the navigation bar
Objective-C
261
star
3

Popover

Custom macOS Popover ๐Ÿ’ฌ
Swift
122
star
4

SegmentedProgressView

๐Ÿ”˜๐Ÿ”˜๐Ÿ”˜โšช๏ธโšช๏ธ Simple Instagram-like segmented progress view with completion handler and different time interval for each segment
Swift
92
star
5

Snackbar

A Snackbar for macOS applications
Swift
13
star
6

SoundPlayer

๐Ÿ”ŠSuper simple, low-latency sound player.
Swift
4
star
7

StatesController

UIViewController which implements switching states: Loading, No Data, Error and Content
Swift
4
star
8

LaRevenueCat

LaMetric dashboard for RevenueCat
Swift
3
star
9

Anchor

Swift
3
star
10

CopyIt

Showing Copy menu for each and every view in your app โœ‚๏ธ
Swift
2
star
11

LoadingViewController

View controller which supports changing of it's content with predefined views: ContentView, LoadingView, ErrorView, NoDataView
Swift
2
star
12

ThumbnailsGenerator

Swift
2
star
13

Lasso

Intuitive and native Window Manager for Mac
2
star
14

InstagramStoryTransition

Swift
1
star
15

Widgy

1
star
16

CleanSwiftXCodeTemplates

Makefile
1
star
17

EventMonitor

Swift
1
star
18

AquaSmartGUI

C
1
star
19

Menu-Example

Example app for custom Mac OS Menu
Swift
1
star
20

SlidingButton

Swift
1
star
21

ViewPushBack

UIView push back
Objective-C
1
star
22

FamilyPocket-iOS

Simple app for family budget tracking ๐Ÿ’ฐ
Swift
1
star
23

Altum

1
star
24

simctrl

Swift package which implements simctl functionality
Swift
1
star