0

I am having a bug while adding an Object (Slider Card -- Photo of slider Card) on another Object (The background, and the map) What it does is stack 2 objects vertically (The bug), I assume it is because I use VStack. Is there a function that I can use to make the slider in front of the background? Thank you in advance.

import SwiftUI

struct ContentView: View {
    let locations = ["Subaru WRX", "Tesla Model 3", "Porsche 911", "Renault Zoe", "DeLorean","Tony's Car"]
    @State private var searchText : String = ""
   
    var view = UILabel(frame:CGRect(x: 0, y: 0, width: 335, height: 29))
    @State var slideBar = CGSize.zero
    var body: some View {
        VStack {
            Label(
                title: {Text("EcoFit")},
                icon: {Image("logo")
                        .resizable()
                            .frame(width: 128.0, height: 64.0)
                }
            ).labelStyle(IconOnlyLabelStyle())
            SearchBar(text: $searchText)
            HStack {
                Spacer()
                Button(action: {
                }){
                    Text("Bike")
                }
                Spacer()
                Button(action: {
                }){
                    Text("Bus")
                }
                Spacer()
                Button(action: {
                }){
                    Text("Scooter")
                }
                Spacer()
                Button(action: {
                }){
                    Text("Walk")
                }
                Spacer()
                
            }
            List{
                ForEach(self.locations.filter {
                    self.searchText.isEmpty ? true : $0.contains(self.searchText)
                }, id: \.self) { car in Text(car)
                }
            }
            .searchable(text: $searchText){
                ForEach(self.locations.filter {
                    self.searchText.isEmpty ? true : $0.contains(self.searchText)
                }, id: \.self) { result in Text("Are you looking for \(result)").searchCompletion(result)
                }
            }
            Card() <----- slider card here!!
        }
        .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
        .background(Color.white)
       
    }
    
}
  • Have a look at [this](https://stackoverflow.com/questions/60967872/swiftui-sheet-modals-with-custom-size-on-ipad). It may give you some clues. – Ptit Xav Mar 27 '22 at 10:12
  • You also look at [this](https://stackoverflow.com/questions/70578561/resize-sheet-presentation-swiftui). And you may find what you need in [SheeKit](https://github.com/edudnyk/SheeKit) on GitHub – Ptit Xav Mar 27 '22 at 10:19

0 Answers0