aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift
diff options
context:
space:
mode:
authorEric Kuck <eric@bluelinelabs.com>2018-12-13 12:58:50 -0600
committerEric Kuck <eric@bluelinelabs.com>2018-12-13 12:58:50 -0600
commit05d750539b91eff582ff6a789fcdcab73bb5f7bb (patch)
tree0a59939a0805567ea1c4b310d78e4d4c9394cb96 /WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift
parentAvoid escaping heap allocation (diff)
downloadwireguard-apple-05d750539b91eff582ff6a789fcdcab73bb5f7bb.tar.xz
wireguard-apple-05d750539b91eff582ff6a789fcdcab73bb5f7bb.zip
Reorganized ViewControllers (split out UIViews and UITableViewCells into their own classes)
All swiftlint warnings except one fixed up Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift30
1 files changed, 14 insertions, 16 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift b/WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift
index f2d0f58..bd6f547 100644
--- a/WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift
+++ b/WireGuard/WireGuard/UI/iOS/ScrollableLabel.swift
@@ -13,33 +13,31 @@ class ScrollableLabel: UIScrollView {
set(value) { label.textColor = value }
}
- let label: UILabel
-
- init() {
+ let label: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textAlignment = .right
- self.label = label
+ return label
+ }()
+ init() {
super.init(frame: CGRect.zero)
- self.isDirectionalLockEnabled = true
- self.showsHorizontalScrollIndicator = false
- self.showsVerticalScrollIndicator = false
+ isDirectionalLockEnabled = true
+ showsHorizontalScrollIndicator = false
+ showsVerticalScrollIndicator = false
addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
- label.leftAnchor.constraint(equalTo: self.contentLayoutGuide.leftAnchor),
- label.topAnchor.constraint(equalTo: self.contentLayoutGuide.topAnchor),
- label.bottomAnchor.constraint(equalTo: self.contentLayoutGuide.bottomAnchor),
- label.rightAnchor.constraint(equalTo: self.contentLayoutGuide.rightAnchor),
- label.heightAnchor.constraint(equalTo: self.heightAnchor)
+ label.leftAnchor.constraint(equalTo: contentLayoutGuide.leftAnchor),
+ label.topAnchor.constraint(equalTo: contentLayoutGuide.topAnchor),
+ label.bottomAnchor.constraint(equalTo: contentLayoutGuide.bottomAnchor),
+ label.rightAnchor.constraint(equalTo: contentLayoutGuide.rightAnchor),
+ label.heightAnchor.constraint(equalTo: heightAnchor)
])
- // If label has less content, it should expand to fit the scrollView,
- // so that right-alignment works in the label.
- let expandToFitValueLabelConstraint = NSLayoutConstraint(item: label, attribute: .width, relatedBy: .equal,
- toItem: self, attribute: .width, multiplier: 1, constant: 0)
+
+ let expandToFitValueLabelConstraint = NSLayoutConstraint(item: label, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1, constant: 0)
expandToFitValueLabelConstraint.priority = .defaultLow + 1
expandToFitValueLabelConstraint.isActive = true
}