Using UIViewRepresentable to wrap MarqueeLabel view
It is by-default expanded by intrinsic content to full width, so MarqueeLabel
just does not have what to scroll - everything is in frame.
In such cases we need to give ability to parent to shrink internal view to externally available space (by width in this case to screen)
so here is a fix - decrease resistance priority:
func makeUIView(context: UIViewRepresentableContext<UILabelView>) -> MarqueeLabel {
let label = MarqueeLabel()
label.text = text
label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
// ^^^^^ << this one !!
return label
}
Tested with Xcode 13.4 / iOS 15.5
How to find the frame of a SwiftUI UIViewRepresentable
It is due to use of GeometryReader
Try to use
custonView(model:self.model)
.fixedSize()
Related Topics
Tapping Is Required Twice to Uncheck Table Cell
Xcode Swift: Could Not Insert New Outlet Connection
How to Show Cluster for Mkpolyline with Geojson Data View in iOS Swift
Syntax to Create Dictionary in Swift
Working Out The Start and End of a Day. Swift
Why Does Editing a Textfield Throw a Nsinvalidargumentexception
Why Extensions Cannot Add Stored Properties
Protocol with Associatedtype Protocol for Generic Functions
Transparency Issues with Repeated Stamping of Textures on an Mtkview
Cannot Use Mutating Member on Immutable Value of Type 'string'
Using UIviewrepresentable to Wrap Marqueelabel View
Nstimer() - Timer.Invalidate Not Working on a Simple Stopwatch
Issues with Uploading from Xcode 9 to App Store/ Itunes Connect
Not Getting Screenlock Notification on Swift 4 on Mac
Macos, Swift 3: How to Get Data Back After Segue