Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI and tvOS: adjustsImageWhenAncestorFocused

Tags:

swiftui

tvos

How do you get the same focus effect in SwiftUI for images as you can with UIKit? I see you can use the card button style and it does provide motion effects but not the parallax that adjustsImageWhenAncestorFocused provides.

struct ContentView: View {
    var body: some View {
        Button {
            print("tapped")
        } label: {
            AsyncImage(url: URL(string: "Image-URL"))
                .frame(width: 300, height: 300)
        }
        .buttonStyle(.card)
    }
}
like image 893
Andrew Conlan Avatar asked Oct 30 '25 10:10

Andrew Conlan


1 Answers

I know this question is pretty old, but I ran into the same problem and found that wrapping your UIImageView in a UIViewRepresentable works just fine.

like image 60
Kris9000 Avatar answered Nov 01 '25 14:11

Kris9000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!