aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift
diff options
context:
space:
mode:
authorEric Kuck <eric@bluelinelabs.com>2018-12-14 17:27:11 -0600
committerEric Kuck <eric@bluelinelabs.com>2018-12-14 17:27:11 -0600
commitcb051f695db44e7a52e3f423fa27de00c493a9ac (patch)
tree64b583809b17825a0660211f7f381dfc892ccf61 /WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift
parentMost similar views now shared between ViewControllers (diff)
downloadwireguard-apple-cb051f695db44e7a52e3f423fa27de00c493a9ac.tar.xz
wireguard-apple-cb051f695db44e7a52e3f423fa27de00c493a9ac.zip
Reorganized project structure
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift')
-rw-r--r--WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift48
1 files changed, 48 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift b/WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift
new file mode 100644
index 0000000..bd6f547
--- /dev/null
+++ b/WireGuard/WireGuard/UI/iOS/View/ScrollableLabel.swift
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018 WireGuard LLC. All Rights Reserved.
+
+import UIKit
+
+class ScrollableLabel: UIScrollView {
+ var text: String {
+ get { return label.text ?? "" }
+ set(value) { label.text = value }
+ }
+ var textColor: UIColor {
+ get { return label.textColor }
+ set(value) { label.textColor = value }
+ }
+
+ let label: UILabel = {
+ let label = UILabel()
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.textAlignment = .right
+ return label
+ }()
+
+ init() {
+ super.init(frame: CGRect.zero)
+
+ isDirectionalLockEnabled = true
+ showsHorizontalScrollIndicator = false
+ showsVerticalScrollIndicator = false
+
+ addSubview(label)
+ label.translatesAutoresizingMaskIntoConstraints = false
+ NSLayoutConstraint.activate([
+ 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)
+ ])
+
+ let expandToFitValueLabelConstraint = NSLayoutConstraint(item: label, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1, constant: 0)
+ expandToFitValueLabelConstraint.priority = .defaultLow + 1
+ expandToFitValueLabelConstraint.isActive = true
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+}