Make alt text selectable
This commit is contained in:
parent
754b0a7eb0
commit
7ab6ea0d23
|
@ -9,7 +9,7 @@ import SwiftUI
|
||||||
|
|
||||||
class AltViewController: UIViewController {
|
class AltViewController: UIViewController {
|
||||||
private var alt: String
|
private var alt: String
|
||||||
let label = UILabel()
|
let label = UITextView()
|
||||||
|
|
||||||
init(alt: String, sourceView: UIView?) {
|
init(alt: String, sourceView: UIView?) {
|
||||||
self.alt = alt
|
self.alt = alt
|
||||||
|
@ -29,10 +29,20 @@ class AltViewController: UIViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
label.numberOfLines = 0
|
label.textContainer.maximumNumberOfLines = 0
|
||||||
label.lineBreakMode = .byWordWrapping
|
label.textContainer.lineBreakMode = .byWordWrapping
|
||||||
label.lineBreakStrategy = .standard
|
label.textContainerInset = UIEdgeInsets(
|
||||||
|
top: 8,
|
||||||
|
left: 0,
|
||||||
|
bottom: -label.textContainer.lineFragmentPadding,
|
||||||
|
right: 0
|
||||||
|
)
|
||||||
label.font = .preferredFont(forTextStyle: .callout)
|
label.font = .preferredFont(forTextStyle: .callout)
|
||||||
|
label.isScrollEnabled = false
|
||||||
|
label.backgroundColor = .clear
|
||||||
|
label.isOpaque = false
|
||||||
|
label.isEditable = false
|
||||||
|
label.tintColor = .white
|
||||||
label.text = alt
|
label.text = alt
|
||||||
|
|
||||||
view.translatesAutoresizingMaskIntoConstraints = false
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -42,7 +52,7 @@ class AltViewController: UIViewController {
|
||||||
NSLayoutConstraint.constraints(withVisualFormat: "V:|-[label]-|", metrics: nil, views: ["label": label])
|
NSLayoutConstraint.constraints(withVisualFormat: "V:|-[label]-|", metrics: nil, views: ["label": label])
|
||||||
)
|
)
|
||||||
NSLayoutConstraint.activate(
|
NSLayoutConstraint.activate(
|
||||||
NSLayoutConstraint.constraints(withVisualFormat: "H:|-[label]-|", metrics: nil, views: ["label": label])
|
NSLayoutConstraint.constraints(withVisualFormat: "H:|-(8)-[label]-(8)-|", metrics: nil, views: ["label": label])
|
||||||
)
|
)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
label.widthAnchor.constraint(lessThanOrEqualToConstant: 400),
|
label.widthAnchor.constraint(lessThanOrEqualToConstant: 400),
|
||||||
|
|
Loading…
Reference in New Issue