-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCell.swift
97 lines (71 loc) · 2.21 KB
/
Cell.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Cell.swift
// CollectionViewAnimations
//
// Created by Christian Noon on 10/29/15.
// Copyright © 2015 Noondev. All rights reserved.
//
import UIKit
class ContentCell: UICollectionViewCell {
class var reuseIdentifier: String { return "\(self)" }
class var kind: String { return "ContentCell" }
var label: UILabel!
// MARK: Initialization
override init(frame: CGRect) {
super.init(frame: frame)
label = {
let label = UILabel()
label.font = UIFont.systemFontOfSize(20)
label.textColor = UIColor.whiteColor()
return label
}()
contentView.addSubview(label)
label.snp_makeConstraints { make in
make.center.equalTo(contentView)
}
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
override func prepareForReuse() {
UIView.performWithoutAnimation {
self.backgroundColor = nil
}
}
// MARK: Layout
override func applyLayoutAttributes(layoutAttributes: UICollectionViewLayoutAttributes) {
super.applyLayoutAttributes(layoutAttributes)
layoutIfNeeded()
}
}
// MARK: -
class SectionHeaderCell: UICollectionReusableView {
class var reuseIdentifier: String { return "\(self)" }
class var kind: String { return "SectionHeaderCell" }
var label: UILabel!
// MARK: Initialization
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.2, alpha: 1.0)
label = {
let label = UILabel()
label.font = UIFont.boldSystemFontOfSize(14)
label.textColor = UIColor.whiteColor()
return label
}()
addSubview(label)
label.snp_makeConstraints { make in
make.leading.equalTo(self).offset(20)
make.trailing.equalTo(self).offset(-20)
make.centerY.equalTo(self)
}
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
// MARK: Layout
override func applyLayoutAttributes(layoutAttributes: UICollectionViewLayoutAttributes) {
super.applyLayoutAttributes(layoutAttributes)
layoutIfNeeded()
}
}