forked from kaunteya/ProgressKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseView.swift
53 lines (44 loc) · 1.3 KB
/
BaseView.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
//
// BaseView.swift
// ProgressKit
//
// Created by Kauntey Suryawanshi on 04/10/15.
// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved.
//
import AppKit
@IBDesignable
public class BaseView : NSView {
override public init(frame frameRect: NSRect) {
super.init(frame: frameRect)
self.configureLayers()
}
required public init?(coder: NSCoder) {
super.init(coder: coder)
self.configureLayers()
}
/// Configure the Layers
func configureLayers() {
self.wantsLayer = true
notifyViewRedesigned()
}
@IBInspectable public var background: NSColor = NSColor(red: 88.3 / 256, green: 104.4 / 256, blue: 118.5 / 256, alpha: 1.0) {
didSet {
self.notifyViewRedesigned()
}
}
@IBInspectable public var foreground: NSColor = NSColor(red: 66.3 / 256, green: 173.7 / 256, blue: 106.4 / 256, alpha: 1.0) {
didSet {
self.notifyViewRedesigned()
}
}
@IBInspectable public var cornerRadius: CGFloat = 5.0 {
didSet {
self.notifyViewRedesigned()
}
}
/// Call when any IBInspectable variable is changed
func notifyViewRedesigned() {
self.layer?.backgroundColor = background.CGColor
self.layer?.cornerRadius = cornerRadius
}
}