Skip to content

A sample demonstrating a SwiftUI problem

License

Notifications You must be signed in to change notification settings

aoverholtzer/SampleLabel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SampleLabel

Prime Objective

Display a multi-line NSAttributedString in SwiftUI

What Have I Done So Far

Search around the web and implemented a UIViewRepresentable:

struct AttributedText: UIViewRepresentable {

  var text: NSAttributedString

  func makeUIView(context: Context) -> UILabel {
    let label = UILabel()
    label.numberOfLines = 0
    label.lineBreakMode = .byWordWrapping
    return label
  }

  func updateUIView(_ label: UILabel, context: Context) {
    label.attributedText = text
  }
}

What Is The Problem?

alt text

The label shows only one, long line of text. A UITest to check for the correct behavior is included

Any idea what I could do?

About

A sample demonstrating a SwiftUI problem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%