This is SwiftUI written in Xcode 11.6, targeting iOS 13.
Has anyone gotten a UIColor initialized from a pattern image to render in the presence of SwiftUI?
I have a function that creates a UIImage 128x128 pattern of diagonal lines. The intention is to pass it to UIColor.init(patternImage:) So, two products, the image and the pattern color.
The colors render as the backgroundColor for a UIView in a pure-UIKit app. In all cases, the pattern color shows in the console as a UIColor wrapping an image.
The map delegate's method mapView(_:rendererFor:) creates the renderer, sets the fill color to the pattern, sets alpha to 1.0. The overlays render as approximately black, 50% alpha.
Moving the delegate object to a file importing only UIKit and MapKit doesn't make the pattern color render.
What am I missing? I've heard pattern colors aren't supported by SwiftUI, but I wouldn't think it'd poison code in a UIKit enclave. They're supposed to be interoperable, right? "Don't worry, you can adopt in phases?"
Has anyone gotten a UIColor initialized from a pattern image to render in the presence of SwiftUI?
I have a function that creates a UIImage 128x128 pattern of diagonal lines. The intention is to pass it to UIColor.init(patternImage:) So, two products, the image and the pattern color.
Works
When I render the images, they look fine, in Playground, in the Xcode debugger, in SwiftUI.Image, in a UIImageView of a pure-UIKit app.The colors render as the backgroundColor for a UIView in a pure-UIKit app. In all cases, the pattern color shows in the console as a UIColor wrapping an image.
Doesn't work
The pattern colors render nowhere else, simulator or device. Playground "previews" the color (SwiftUI not imported) as "Unable to encode pattern colors at this time." No logs in any other environment.Intended use
The intended use is as the fill color for an MKOverlay: Areas are rendered in colors according to a statistic; where the statistic is unavailable, I'd like to hash the overlay out.The map delegate's method mapView(_:rendererFor:) creates the renderer, sets the fill color to the pattern, sets alpha to 1.0. The overlays render as approximately black, 50% alpha.
Moving the delegate object to a file importing only UIKit and MapKit doesn't make the pattern color render.
What am I missing? I've heard pattern colors aren't supported by SwiftUI, but I wouldn't think it'd poison code in a UIKit enclave. They're supposed to be interoperable, right? "Don't worry, you can adopt in phases?"