-
Notifications
You must be signed in to change notification settings - Fork 12
/
HorizontalAlignmentViewController.swift
93 lines (77 loc) · 3.79 KB
/
HorizontalAlignmentViewController.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
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import UIKit
import Lima
class HorizontalAlignmentViewController: UIViewController {
override func loadView() {
let phoneIcon = UIImage(systemName: "phone.fill")
let faxIcon = UIImage(systemName: "printer.fill")
let emailIcon = UIImage(systemName: "envelope.fill")
let cellStyle = { (cell: UIView) in
cell.layer.borderWidth = 0.5
cell.layer.borderColor = UIColor.lightGray.cgColor
}
view = LMScrollView(isFitToWidth: true, backgroundColor: .white,
LMColumnView(margin: 8,
// Leading alignment
UILabel(text: "Leading", font: .systemFont(ofSize: 14)),
LMRowView(margin: 8, horizontalAlignment: .leading,
UIImageView(image: phoneIcon, tintColor: .black),
UIImageView(image: faxIcon, tintColor: .black),
UIImageView(image: emailIcon, tintColor: .black),
with: cellStyle
),
LMColumnView(margin: 8, horizontalAlignment: .leading,
UIImageView(image: phoneIcon, tintColor: .black),
UIImageView(image: faxIcon, tintColor: .black),
UIImageView(image: emailIcon, tintColor: .black),
with: cellStyle
),
LMSpacer(height: 0.5, backgroundColor: .gray),
// Trailing alignment
UILabel(text: "Trailing", font: .systemFont(ofSize: 14)),
LMRowView(margin: 8, horizontalAlignment: .trailing,
UIImageView(image: phoneIcon, tintColor: .black),
UIImageView(image: faxIcon, tintColor: .black),
UIImageView(image: emailIcon, tintColor: .black),
with: cellStyle
),
LMColumnView(margin: 8, horizontalAlignment: .trailing,
UIImageView(image: phoneIcon, tintColor: .black),
UIImageView(image: faxIcon, tintColor: .black),
UIImageView(image: emailIcon, tintColor: .black),
with: cellStyle
),
LMSpacer(height: 0.5, backgroundColor: .gray),
// Center alignment
UILabel(text: "Center", font: .systemFont(ofSize: 14)),
LMColumnView(margin: 8, horizontalAlignment: .center,
UIImageView(image: phoneIcon, tintColor: .black),
UIImageView(image: faxIcon, tintColor: .black),
UIImageView(image: emailIcon, tintColor: .black),
with: cellStyle
),
LMSpacer(height: 0.5, backgroundColor: .gray),
// Fill alignment
UILabel(text: "Fill", font: .systemFont(ofSize: 14)),
LMRowView(margin: 8, horizontalAlignment: .fill,
UIImageView(image: phoneIcon, contentMode: .center, tintColor: .black, weight: 1),
UIImageView(image: faxIcon, contentMode: .center, tintColor: .black, weight: 1),
UIImageView(image: emailIcon, contentMode: .center, tintColor: .black, weight: 1),
with: cellStyle
)
)
)
}
}