Last active
January 23, 2017 15:05
-
-
Save eonist/924209f6b54a5b415b7a59a4274d95a4 to your computer and use it in GitHub Desktop.
swift 3.0, NSButton, NSTextField (Experiment) (standalone window)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//forked from: https://github.com/BergQuester/Interactive-Window-Swift-Playground | |
import Cocoa | |
import XCPlayground | |
// Window size | |
let windowRect = NSRect(x: 30, y: 30, width: 300, height: 300) | |
var window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 300, height: 300), styleMask: NSWindowStyleMask.titled, backing: .buffered, defer: false) | |
// Configure window here | |
// Content view | |
let viewRect = NSRect(x: 0, y: 0, width: 200, height: 200) | |
var view:NSView = NSView(frame: viewRect) | |
// configure your content view and add subviews here | |
var textField = NSTextField(frame: NSRect(x: 30, y: 30, width: 100, height: 20)) | |
textField.stringValue = "Test" | |
view.addSubview(textField) | |
var button = NSButton(frame: NSRect(x: 30, y: 60, width: 100, height: 30)) | |
button.highlight(true) | |
var buttonCell:NSButtonCell = button.cell as! NSButtonCell | |
buttonCell.bezelStyle = NSBezelStyle.rounded | |
view.addSubview(button) | |
// display window | |
window.contentView = view | |
window.makeKeyAndOrderFront(nil) | |
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment