Changed AttributedStringView to use UITextView
This commit is contained in:
parent
3ca0934ecb
commit
3a359f0e37
|
@ -17,18 +17,18 @@ struct SettingsAboutView: View {
|
|||
GeometryReader { geometry in
|
||||
List {
|
||||
Text("NetNewsWire").font(.largeTitle)
|
||||
AttributedStringView(string: self.viewModel.about, preferredMaxLayoutWidth: geometry.size.width - 40)
|
||||
AttributedStringView(string: self.viewModel.about, preferredMaxLayoutWidth: geometry.size.width - 20)
|
||||
Section(header: Text("CREDITS")) {
|
||||
AttributedStringView(string: self.viewModel.credits, preferredMaxLayoutWidth: geometry.size.width - 40)
|
||||
AttributedStringView(string: self.viewModel.credits, preferredMaxLayoutWidth: geometry.size.width - 20)
|
||||
}
|
||||
Section(header: Text("ACKNOWLEDGEMENTS")) {
|
||||
AttributedStringView(string: self.viewModel.acknowledgements, preferredMaxLayoutWidth: geometry.size.width - 40)
|
||||
AttributedStringView(string: self.viewModel.acknowledgements, preferredMaxLayoutWidth: geometry.size.width - 20)
|
||||
}
|
||||
Section(header: Text("THANKS")) {
|
||||
AttributedStringView(string: self.viewModel.thanks, preferredMaxLayoutWidth: geometry.size.width - 40)
|
||||
AttributedStringView(string: self.viewModel.thanks, preferredMaxLayoutWidth: geometry.size.width - 20)
|
||||
}
|
||||
Section(header: Text("DEDICATION"), footer: Text("Copyright © 2002-2019 Ranchero Software").font(.footnote)) {
|
||||
AttributedStringView(string: self.viewModel.dedication, preferredMaxLayoutWidth: geometry.size.width - 40)
|
||||
AttributedStringView(string: self.viewModel.dedication, preferredMaxLayoutWidth: geometry.size.width - 20)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,17 +13,18 @@ struct AttributedStringView: UIViewRepresentable {
|
|||
let string: NSAttributedString
|
||||
let preferredMaxLayoutWidth: CGFloat
|
||||
|
||||
func makeUIView(context: Context) -> UILabel {
|
||||
return UILabel()
|
||||
func makeUIView(context: Context) -> HackedTextView {
|
||||
return HackedTextView()
|
||||
}
|
||||
|
||||
func updateUIView(_ view: UILabel, context: Context) {
|
||||
func updateUIView(_ view: HackedTextView, context: Context) {
|
||||
view.attributedText = string
|
||||
|
||||
view.numberOfLines = 0
|
||||
view.lineBreakMode = .byWordWrapping
|
||||
view.preferredMaxLayoutWidth = preferredMaxLayoutWidth
|
||||
|
||||
view.isScrollEnabled = false
|
||||
view.textContainer.lineBreakMode = .byWordWrapping
|
||||
|
||||
view.isUserInteractionEnabled = true
|
||||
view.adjustsFontForContentSizeCategory = true
|
||||
view.font = .preferredFont(forTextStyle: .body)
|
||||
view.textColor = UIColor.label
|
||||
|
@ -35,3 +36,10 @@ struct AttributedStringView: UIViewRepresentable {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class HackedTextView: UITextView {
|
||||
var preferredMaxLayoutWidth = CGFloat.zero
|
||||
override var intrinsicContentSize: CGSize {
|
||||
return sizeThatFits(CGSize(width: preferredMaxLayoutWidth, height: .infinity))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue