Wednesday, February 8, 2023
HomeiOS Developmentios - Displaying button based mostly on the scrolling standing

ios – Displaying button based mostly on the scrolling standing


I am fairly new in growth and in SwiftUI. I discovered a little bit with the Paul Hudson programs and by my self and I started to develop my first app however I am going through a little bit downside that I can not resolve alone…

I’ve a view with some lengthy textual content and I embed it in a scrollView. To indicate consumer there’s a scrollable textual content I add this little arrow on the backside on my Textual content however I need to present it solely when the textual content is lengthy sufficient to not present fully with out scrolling.
And if it is confirmed i want it to vanish when the underside of the scrollView is reached and reappear when the consumer scroll again on prime…

I allow you to my code right here :

VStack {
            Textual content("Lorem ipsum in my TestView")
                .font(.title)
                .padding(.backside, 20)
            
            ScrollViewReader { proxy in
                ScrollView {
                    
                    Textual content("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed accumsan mi elementum metus eleifend fermentum. Vestibulum a ligula laoreet libero rhoncus pharetra. Vivamus ac erat non odio tempus iaculis. Phasellus tincidunt dapibus ultricies. Aliquam erat volutpat. Maecenas aliquam est felis. Etiam consectetur viverra velit. Phasellus ligula metus, congue quis est vel, fermentum euismod ligula. Nunc pulvinar luctus semper. Nunc non fringilla ligula. Morbi scelerisque, augue non tempus hendrerit, tellus lectus sagittis ex, nec volutpat mi lacus maximus elit.").padding()
                    Textual content("").padding(.backside, 10)
                        .id("finish")
                    
                }.body(maxWidth: 300, maxHeight: 100)
                    .padding()
                    .background(.quaternary)
                    .clipShape(RoundedRectangle(cornerRadius: 10))
                
                if showBottom {
                    Button{
                        withAnimation {
                            proxy.scrollTo("finish")
                            showBottom.toggle()
                        }
                    } label: {
                        Picture(systemName: "chevron.down.circle.fill")
                    }
                    
                }
            }

And there’s a screenshot and a video to point out the issue :

Screenshot

Video :
Display report

I attempted to get the scroll standing with scrollViewReader to point out and conceal the button however did not work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments