forked from michiamling/SpreadsheetView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGridlines.swift
63 lines (53 loc) · 1.36 KB
/
Gridlines.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
//
// Gridlines.swift
// SpreadsheetView
//
// Created by Kishikawa Katsumi on 5/7/17.
// Copyright © 2017 Kishikawa Katsumi. All rights reserved.
//
import UIKit
public struct Gridlines {
public var top: GridStyle
public var bottom: GridStyle
public var left: GridStyle
public var right: GridStyle
public static func all(_ style: GridStyle) -> Gridlines {
return Gridlines(top: style, bottom: style, left: style, right: style)
}
}
public enum GridStyle {
case `default`
case none
case solid(width: CGFloat, color: UIColor)
}
extension GridStyle: Equatable {
public static func ==(lhs: GridStyle, rhs: GridStyle) -> Bool {
switch (lhs, rhs) {
case (.none, .none):
return true
case let (.solid(lWidth, lColor), .solid(rWidth, rColor)):
return lWidth == rWidth && lColor == rColor
default:
return false
}
}
}
final class Gridline: CALayer {
var color: UIColor = .clear {
didSet {
backgroundColor = color.cgColor
}
}
override init() {
super.init()
}
override init(layer: Any) {
super.init(layer: layer)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func action(forKey event: String) -> CAAction? {
return nil
}
}