/
ExampleApplicationController.swift
79 lines (61 loc) · 2.62 KB
/
ExampleApplicationController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// ExampleApplicationController.swift
// SplitViewExample
//
// Created by Hoon H. on 10/12/14.
// Copyright (c) 2014 Eonil. All rights reserved.
//
import Cocoa
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// New approach. Precise round corner. Also masks content view properly.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ExampleApplicationController: NSObject, NSApplicationDelegate {
class ExampleController {
let window1 = NSWindow()
init(){
window1.backgroundColor = NSColor.whiteColor()
window1.opaque = false
window1.styleMask = NSResizableWindowMask
| NSTitledWindowMask
| NSFullSizeContentViewWindowMask
window1.movableByWindowBackground = true
window1.titlebarAppearsTransparent = true
window1.titleVisibility = .Hidden
window1.showsToolbarButton = false
window1.standardWindowButton(NSWindowButton.FullScreenButton)?.hidden = true
window1.standardWindowButton(NSWindowButton.MiniaturizeButton)?.hidden = true
window1.standardWindowButton(NSWindowButton.CloseButton)?.hidden = true
window1.standardWindowButton(NSWindowButton.ZoomButton)?.hidden = true
window1.setFrame(CGRect(x: 400, y: 0, width: 400, height: 500), display: true)
window1.makeKeyAndOrderFront(self)
}
}
let example1 = ExampleController()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Old approach. Impossible to provide precise round corner.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//class ExampleApplicationController: NSObject, NSApplicationDelegate {
// class ExampleController {
//
// let window1 = NSWindow()
// let view1 = NSView()
//
// init(){
// window1.setFrame(CGRect(x: 400, y: 0, width: 400, height: 500), display: true)
// window1.contentView = view1
//
// window1.backgroundColor = NSColor.clearColor()
// window1.opaque = false
// window1.styleMask = NSBorderlessWindowMask | NSResizableWindowMask
// window1.movableByWindowBackground = true
// window1.makeKeyAndOrderFront(self)
//
// view1.wantsLayer = true
// view1.layer!.cornerRadius = 5
// view1.layer!.backgroundColor = NSColor.whiteColor().CGColor
// }
// }
//
// let example1 = ExampleController()
//}