在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):iSapozhnik/Popover开源软件地址(OpenSource Url):https://github.com/iSapozhnik/Popover开源编程语言(OpenSource Language):Swift 100.0%开源软件介绍(OpenSource Introduction):Popover
InstallSince this is a Swift Package, the installation process is pretty stright forward. Manual wayUpdate your
Via Xcode:
How to use
And here is how typical import Cocoa
import Popover
class MyPopoverConfiguration: DefaultConfiguration {
override var backgroundColor: NSColor {
return NSColor.systemRed
}
override var borderColor: NSColor? {
return NSColor.red
}
}
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var popover: Popover!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let statusItemView = StatusItemView(frame: NSRect(width: 22.0, height: 20))
let viewController = MainViewController()
let menuItems: [Popover.MenuItemType] = [
.item(Popover.MenuItem(title: "Settings", action: viewController.showSettings)),
.separator,
.item(Popover.MenuItem(title: "Quit", key: "q", action: viewController.quit))
]
popover = Popover(with: MyPopoverConfiguration(), menuItems: menuItems)
popover.prepare(with: statusItemView, contentViewController: viewController)
}
}
What can be customized?Quite a lot of things: public protocol PopoverConfiguration {
/// The distance from Popover's arrow to a status item.
var popoverToStatusItemMargin: CGFloat { get }
/// Popover's background color.
var backgroundColor: NSColor { get }
/// Popover's border color.
/// - Important:
/// If `borderColor` returns `nil`, settings `borderWidth` won't make any effect. See also: `borderWidth`.
var borderColor: NSColor? { get }
/// Popover's border width.
/// - Important:
/// If Popover's border color is set to `nil`, setting `borderWidth` won't make any effect.
var borderWidth: CGFloat { get }
/// Defines Popover arrow height.
var arrowHeight: CGFloat { get }
/// Defines Popover arrow width.
var arrowWidth: CGFloat { get }
/// Defines Popover corner radius.
/// - Warning:
/// If this value is too big and if the Popover's status item (menu bar view) is too close to the right edge, the appearence of the Popover might be odd.
var cornerRadius: CGFloat { get }
/// Defines Popover content edge insets.
var contentEdgeInsets: NSEdgeInsets { get }
/// The distance from the right side of the Popover to the screen's edge.
/// - Warning:
/// If this value is too big and if the Popover's status item (menu bar view) is too close to the right edge, the appearence of the Popover might be odd.
var rightEdgeMargin: CGFloat { get }
} MentionsCreditsCreated and maintained by @iSapozhnik. LicenseReleased under the MIT License. See
Heavily inspired by CCNStatusItem |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论