-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNTPCard.swift
More file actions
41 lines (34 loc) · 1.21 KB
/
NTPCard.swift
File metadata and controls
41 lines (34 loc) · 1.21 KB
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
/*
* @package NTPCard.swift
* @author The Phuc
* @since 7/10/2016.
*/
import UIKit
@IBDesignable
class NTPCard: UIView {
@IBInspectable var cornerRadius: CGFloat = 2
@IBInspectable var shadowOffsetWidth: Int = 0
@IBInspectable var shadowOffsetHeight: Int = 3
@IBInspectable var shadowColor: UIColor? = UIColor.blackColor()
@IBInspectable var shadowOpacity: Float = 0.5
@IBInspectable var backgroundCL: UIColor? = UIColor.whiteColor()
override init(frame: CGRect){
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
internal func setBackground(color: UIColor){
self.backgroundCL = color
}
override func layoutSubviews(){
self.backgroundColor = backgroundCL
layer.cornerRadius = cornerRadius
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius)
layer.masksToBounds = false
layer.shadowColor = shadowColor?.CGColor
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight);
layer.shadowOpacity = shadowOpacity
layer.shadowPath = shadowPath.CGPath
}
}