TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Is it possible to have a listRowBackground that doesn't move with the swipe action?

Forums > SwiftUI

I have some big cards in a List and I would like to reveal extra information behind them when the user swipes. Something not a million miles away from the way you can swipe cards away to reveal buttons in the News app.

My first thought was to try to put something in the listRowBackground but the background seems to move with the swipe action. Is there a way of stopping the background from moving, or perhaps a different approach?

Thanks in advance.

2      

Have you looked at .swipeActions. It might be what you need.

2      

Thanks @NigelGee, I should have been more specific in the OP. .swipeActions is exactly what I was using. But what I am seeing is that the background of the list row moves with that swipe. So for example if I define a LinearGradient in .listRowBackground I can clearly see that the background swipes with the row rather than remaining in place. What I am looking for is a way to keep the background in place during the swipe. May not be possible, but equally possible that I am missing something.

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.