ImagePaint does not work for me any more since (iOS 15) update one year ago.

With

struct ContentView: View {
    var body: some View {
        Rectangle().fill(ImagePaint(image: Image(systemName:"circle.fill").renderingMode(.template),
sourceRect: CGRect(origin: CGPoint.zero,  size:CGSize(width: 100, height: 100)),
scale: 0.009)).foregroundColor(.red)
    }
}

I could draw a rectangle filled with small circles before iOS 15 (last year's update). Since then this does not work any more and I only get "white on white" circles. Searching on Google for a solution only yields very few examples using ImagePaint at all and all of them are from before iOS 15.

How can I get the desired result working again?

I could make it work like this (in iOS 16, Xcode 14 ß2):

struct ContentView: View {
    var body: some View {
        Rectangle()
            .fill(ImagePaint(image: Image("My own image"),
//            .fill(ImagePaint(image: Image(systemName:"circle.fill")
//                .renderingMode(.template),
                             sourceRect: CGRect(origin: CGPoint.zero,
                                                size: CGSize(width: 20, height: 20)),
                             scale: 0.009))
            .foregroundColor(.red)
    }
}
  • systemName apparently doesn't work
  • I had to remove template mode
  • and reduce the size of the sourceRect

Hope that helps.

ImagePaint does not work for me any more since (iOS 15) update one year ago.
 
 
Q