I'm new with this programming language and I'd like to create an application that opens a window with some information when I click a button but I don't know how to do that.
I'm not working with storyboards because I read that for professional programming these doesn't work.
I don't want for iOS, I'd like it to be for OS X.
Regards to all!
Thats pretty simple. You can do as follow:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
let myNewWindow = NSWindow(contentRect: NSMakeRect(0,0,640,480), styleMask: NSBorderlessWindowMask, backing: NSBackingStoreType.Buffered, defer: false)
// NSBorderlessWindowMask = 0,
// NSTitledWindowMask = 1 << 0,
// NSClosableWindowMask = 1 << 1,
// NSMiniaturizableWindowMask = 1 << 2,
// NSResizableWindowMask = 1 << 3,
// NSTexturedBackgroundWindowMask = 1 << 8
func applicationDidFinishLaunching(aNotification: NSNotification) {
// Insert code here to initialize your application
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
@IBAction func btnNewWindow(sender: AnyObject) {
myNewWindow.opaque = false
myNewWindow.movableByWindowBackground = true
myNewWindow.backgroundColor = NSColor(hue: 0, saturation: 1, brightness: 0, alpha: 0.7)
myNewWindow.makeKeyAndOrderFront(nil)
}
}