Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

SwiftUI Documentation

Post

Replies

Boosts

Views

Activity

Questions Tags Saves Users Companies LABS Jobs Discussions COLLECTIVES Communities for your favorite technologies. Explore all Collectives TEAMS Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Looking for your
0 I'm trying to make a list of trips that a person has gone on, and when someone has no trips in their list, it will display a ContentUnavailableView with a NavigationLink to take them to a new view. I am encountering strange issues when using the ContentUnavailableView with the NavigationLink, such as the back button being unaligned and not being able to swipe back to the previous view. I expected the ContentUnavailableView to link without any of these issues. Any guidance would be greatly appreciated.
0
0
75
3d
Location Permission Popup Not Appearing in SwiftUI App
Hello everyone, I'm working on a SwiftUI app that requires location services, and I've implemented a LocationManager class to handle location updates and permissions. However, I'm facing an issue where the location permission popup does not appear when the app is launched. Here is my current implementation: LocationManager.swift: import CoreLocation import SwiftUI class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { private let locationManager = CLLocationManager() @Published var userLocation: CLLocation? @Published var isAuthorized = false @Published var authorizationStatus: CLAuthorizationStatus = .notDetermined override init() { super.init() locationManager.delegate = self checkAuthorizationStatus() } func startLocationUpdates() { locationManager.startUpdatingLocation() } func stopLocationUpdates() { locationManager.stopUpdatingLocation() } func requestLocationAuthorization() { print("Requesting location authorization") DispatchQueue.main.async { self.locationManager.requestWhenInUseAuthorization() } } private func checkAuthorizationStatus() { print("Checking authorization status") authorizationStatus = locationManager.authorizationStatus print("Initial authorization status: \(authorizationStatus.rawValue)") handleAuthorizationStatus(authorizationStatus) } func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { print("Authorization status changed") authorizationStatus = manager.authorizationStatus print("New authorization status: \(authorizationStatus.rawValue)") handleAuthorizationStatus(authorizationStatus) } private func handleAuthorizationStatus(_ status: CLAuthorizationStatus) { switch status { case .authorizedAlways, .authorizedWhenInUse: DispatchQueue.main.async { self.isAuthorized = true self.startLocationUpdates() } case .notDetermined: requestLocationAuthorization() case .denied, .restricted: DispatchQueue.main.async { self.isAuthorized = false self.stopLocationUpdates() print("Location access denied or restricted") } @unknown default: DispatchQueue.main.async { self.isAuthorized = false self.stopLocationUpdates() } } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { DispatchQueue.main.async { self.userLocation = locations.last } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print("Location manager error: \(error.localizedDescription)") } } MapzinApp.swift: @main struct MapzinApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate @StateObject private var locationManager = LocationManager() var body: some Scene { WindowGroup { Group { if locationManager.authorizationStatus == .notDetermined { Text("Determining location authorization status...") } else if locationManager.isAuthorized { CoordinatorView() .environmentObject(locationManager) } else { Text("Location access is required to use this app. Please enable it in Settings.") } } } } } Log input: Checking authorization status Initial authorization status: 0 Requesting location authorization Authorization status changed New authorization status: 0 Requesting location authorization Despite calling requestWhenInUseAuthorization() when the authorization status is .notDetermined, the permission popup never appears. Here are the specific steps I have taken: Checked the Info.plist to ensure the necessary keys for location usage are present: NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription Verified that the app's target settings include location services capabilities. Tested on a real device to ensure it's not a simulator issue. I'm not sure what I might be missing. Any advice or suggestions to resolve this issue would be greatly appreciated. Thank you!
1
0
80
3d
Inline Widget Displays Custom Image Abnormally
I want to display my own image in an inline widget. Using the SwiftUI Image syntax doesn't show the image, so following advice from online forums, I used the syntax Image(uiImage: UIImage(named: String)). This successfully displays the image, but if I change the image file name in the app, the image doesn't update properly. I tested displaying the image file name using Text in the inline widget, and it correctly shows the updated file name from my app. So, my AppStorage and AppGroups seem to be working correctly. I'd like to ask if there's a way to update my images properly and if there's an alternative method to display images without converting them to UIImage. Thanks.
0
0
64
3d
.fullScreenCover Incorrectly Dismissed
Hi, thought I'd share some feedback (which was also sent to Apple) publicly in case anyone else is experiencing the same issue or has an idea of how to circumvent the issue while Apple investigates. TLDR: Views presented with the .fullScreenCover modifier can be incorrectly dismissed when a child view presented with a .sheet modifier inside the .fullScreenCover is dismissed. The intended behavior is that the child sheet views can be dismissed without dismissing the parent full screen cover views. It appears this bug has been present in versions of iOS 17 as well as iOS 18. Short of using something other than a .fullScreenCover to present the view, I'm still searching for a solution to this bug. Filing: FB14007758 Steps to Reproduce (see code below): Open a View in .fullScreenCover presentation In the view presented via the .fullScreenCover, add two sheet modifiers with two different views (e.g. SheetOneView, SheetTwoView) Toggle the presentation of SheetOneView and SheetTwoView randomly until the .fullScreenCover is incorrectly dismissed. Reproducible Code: import SwiftUI struct SheetOneView: View { var body: some View { Text("Sheet: 1") } } struct SheetTwoView: View { var body: some View { Text("Sheet: 2") } } struct FullScreenCoverView: View { @State var isSheetOnePresented = false @State var isSheetTwoPresented = false var body: some View { VStack(content: { Text("Full Screen Cover") HStack { Button("Open Sheet 1") { isSheetOnePresented = true } Button("Open Sheet 2") { isSheetTwoPresented = true } } .buttonStyle(.borderedProminent) .buttonBorderShape(.capsule) }) .sheet(isPresented: $isSheetOnePresented) { SheetOneView() } .sheet(isPresented: $isSheetTwoPresented) { SheetTwoView() } } } struct ContentView: View { @State var isFullScreenCoverPresented = false var body: some View { VStack { Button("Open Full Screen Cover") { isFullScreenCoverPresented = true } } .fullScreenCover(isPresented: $isFullScreenCoverPresented, content: { FullScreenCoverView() }) .padding() } }
1
0
69
3d
Inline Widget Displays Custom Image Abnormally
I want to display my own image in an inline widget. Using the SwiftUI Image syntax doesn't show the image, so following advice from online forums, I used the syntaxImage(uiImage: UIImage(named: String))This successfully displays the image, but if I change the image file name in the app, the image doesn't update properly. I tested displaying the image file name using Text in the inline widget, and it correctly shows the updated file name from my app. So, my AppStorage and AppGroups seem to be working correctly. I'd like to ask if there's a way to update my images properly and if there's an alternative method to display images without converting them to UIImage. Thanks.
0
0
48
3d
Title Bar Height Impact on Window Size in SwiftUI on macOS
In a SwiftUI macOS application, when removing the title bar by setting window.titleVisibility to .hidden and window.titlebarAppearsTransparent to true, the title bar space is still accounted for in the window height. This results in a delta (red area) in the height of the window that cannot be ignored by usual SwiftUI view modifiers like .edgesIgnoringSafeArea(.top). My actual view is the blue area. I want to have the view starting in the top safeArea and the window to be the exact size of my view. I am struggling to achieve this. I have also tried with window.styleMask.insert(.fullSizeContentView) to no effect. Can I get some help? 🙂 Here is my source code to reproduce this behavior: windowApp.swift @main struct windowApp: App { @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate var body: some Scene { WindowGroup { ContentView() .edgesIgnoringSafeArea(.top) .background(.red) .border(.red) } } } class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_ notification: Notification) { if let window = NSApplication.shared.windows.first { window.titleVisibility = .hidden window.titlebarAppearsTransparent = true window.styleMask.insert(.fullSizeContentView) } } } ContentView.swift import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .frame(minWidth: 400, minHeight: 200) .background(.blue) } }
0
0
79
3d
Compact screens, keyboard and dynamic type UI issues
When testing my app on an iPhone SE i noticed an issue with the UI when editing some text in a text field. When the keyboard comes up it pushes everything in the view up and part of the text field gets covered by the navigation title and buttons. It gets worse when testing dynamic fonts and changing the text to XXLarge or higher. There are no issues on a larger screen. Is it possible to prevent the keyboard from push up the content of the view when it is displayed? This is with the default font of large. This is with the extra large text var body: some View { NavigationStack { VStack { HStack { Text("Name") Spacer() TextField("Name", text: $name) .multilineTextAlignment(.trailing) .textFieldStyle(.roundedBorder) .frame(width: 240) .onChange(of: name) { if name.count >= 10 { isShowingLongNameWarning = true } else { isShowingLongNameWarning = false } } } VStack(alignment: .trailing){ HStack { Text("Short Name") Spacer() TextField("Short Name", text: $shortName.max(shortNameCharacterLimit)) .multilineTextAlignment(.trailing) .textFieldStyle(.roundedBorder) .frame(width: isShowingLongNameWarning ? 215 : 240) if isShowingLongNameWarning { VStack { Image(systemName: "exclamationmark.circle") } .popoverTip(shortNameTip) } } Text("Short Name Length: \(shortName.count) characters") .font(.caption) .foregroundStyle(shortName.count >= shortNameCharacterLimit ? .red : .primary) } HStack { Text("Fluid Amount") Spacer() TextField("Fluid Amount", value: $amount, format: .number) .multilineTextAlignment(.trailing) .textFieldStyle(.roundedBorder) .keyboardType(.decimalPad) .focused($numberPadIsFocused) .frame(width: 140) .toolbar { if numberPadIsFocused { ToolbarItemGroup(placement: .keyboard) { Spacer() Button("Done") { numberPadIsFocused = false } } } } } HStack { Text("Unit of Measure") Spacer() Picker("Unit of measure", selection: $unitOfMeasure) { ForEach(FluidUnit.allCases) { Text($0.title) } } .tint(colorScheme == .dark ? .yellow : .pink) } .accessibilityElement() Toggle("Favorite Drink", isOn: $isFavorite) Text("Drink Image") ScrollView(.horizontal) { HStack{ ForEach(DataStore.drinkImages, id: \.self) { image in Button { selectDrinkImage(imageName: image) } label: { ZStack { Image(image) .resizable() .scaledToFit() .frame(height: 100) if imageName == image { SelectedDrinkImageView() } } } .padding(.trailing, 30) } } .scrollTargetLayout() } .scrollIndicators(.hidden) .scrollTargetBehavior(.viewAligned) Spacer() .navigationTitle("Add a Drink") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Save") { addDrink() } .tint(colorScheme == .dark ? .yellow : .pink) .disabled(disableSaveButton()) } ToolbarItem(placement: .topBarLeading) { Button("Cancel") { dismiss() } .tint(colorScheme == .dark ? .yellow : .pink) } } } .padding() } }
0
0
73
4d
TabView Sidebar Style Default?
I'm loving the TabView behaviour, but specifically on a landscape iPad, I'd like to have the app default to sidebar mode. There's tons of space, and for my app it just looks better. I'd like the TabView behaviour everywhere else, though. I know I can set TabView { ... }.tabViewStyle(.sidebarAdaptable) But what I really want is a .sidebarPreferred attribute that uses a sidebar where it would make sense, and a tab bar anywhere else. Even on a portrait iPad I'd like to have the option to have the sidebar style be the default. Is there a way to do this now, or should I open a Feedback? Thanks
1
0
71
4d
Force accessible Color
Looking at Apple's Color Guidelines and taking into account that building my app to work for both light/dark modes I run into an issue where I want to use colors for statuses: red and green. I want to avoid declaring custom colors and I try to use the default ones that adjust for the selected appearance. Unfortunately I noticed that the Color.green does not work well on the default light background of my view (.background(Color (.windowBackgroundColor))) because there is not enough contrast. I noticed that Apple also lists "Accessible" versions of those colors but these are probably managed dynamically. My question: Is there a way to programatically force my app to use the accessible version of a Color (e.g. green)? Thanks
1
0
64
4d
Combining Matched Geometry with New Zoom Navigation Transitions in iOS 18
With the introduction of the new matchedTransitionSource from iOS 18, we can apply a zoom transition in the navigation view using .navigationTransition(.zoom) This works well for zoom animations. However, when I try to apply a matched geometry effect to views that are similar in the source and destination views, the zoom transition works, but those views don't transition seamlessly as they do with a matched geometry effect. Is it possible to still use matched geometry for subviews of the source and destination views along with the new navigationTransition? Here’s a little demo that reproduces this behaviour: struct ContentView: View { let colors: [[Color]] = [ [.red, .blue, .green], [.yellow, .purple, .brown], [.cyan, .gray] ] @Namespace() var namespace var body: some View { NavigationStack { Grid(horizontalSpacing: 50, verticalSpacing: 50) { ForEach(colors, id: \.hashValue) { rowColors in GridRow { ForEach(rowColors, id: \.self) { color in NavigationLink { DetailView(color: color, namespace: namespace) .navigationTransition( .zoom( sourceID: color, in: namespace ) ) .edgesIgnoringSafeArea(.all) } label: { ZStack { RoundedRectangle(cornerRadius: 5) .foregroundStyle(color) .frame(width: 48, height: 48) Image(systemName: "star.fill") .foregroundStyle(Material.bar) .matchedGeometryEffect(id: color, in: namespace, properties: .frame, isSource: false) } } .matchedTransitionSource(id: color, in: namespace) } } } } } } } struct DetailView: View { var color: Color let namespace: Namespace.ID var body: some View { ZStack { color Image(systemName: "star.fill") .resizable() .foregroundStyle(Material.bar) .matchedGeometryEffect(id: color, in: namespace, properties: .frame, isSource: false) .frame(width: 100, height: 100) } .navigationBarHidden(false) } } #Preview { ContentView() }
0
0
113
4d
SwiftUI document-based app bug
I have a simple text editor style app, based on the XCode template of an iOS document-based app. Everything works really – except the unfolding of the dropdown on the first opening of a new file. On real hardware (eg. my iPhone or iPad) it is consistently a problem. Everything is up-to-date and rebooted etc. etc. On the XCode Simulator, I can't get it to do it. I've included 3 screenshots, one showing how it should look when properly unfolded on the XCode Simulator, the other when it hasn't unfolded properly on the first opening of a document, and lastly, subsequent visits to that dropdown and it will behave correctly.
0
0
56
4d
TipKit: Popover Tip w/ use of Menu in Toolbar
As the title states, I'm trying to apply a .popoverTip to a Menu { } which is inside of a .toolbar { }. The toolbar has default placement and the menu includes a toggle button, and a NavigationLink. I've ensured that tips can show on the view by using a TipView(tip: ) within my view which displays. Am I missing something? Is this not possible? Alternatively, can anyone recommend a method to potentially debug why a tip won't show for future debugging?
1
0
100
4d
View identities updated on every keystroke in .searchable
I have a SwiftUI list that is backed by a @FetchRequest to Core Data. To display the items in the list it is necessary to traverse relationships on the originally fetched objects and currently the fetch is a little bit slow, while a number of the objects being displayed require images to be rendered, so overall it is a heavy view at present. I am working to make both the view rendering and the fetch more efficient, but alongside that I tried to improve the user experience by debouncing the connection between the user's search text and when the predicate would be updated on the @FetchRequest. This was quite simple to do, and meant the source data would only be re-fetched when the user had stopped typing for at least 0.5 seconds. However, what this demonstrated was that with a .searchable attached to the list, all items in the list were being updated on every keystroke, with printing changes revealing it was because their identity itself was changing, rather than any content. I found this was still the case even if I completely removed my updating of the predicate, so the text binding from the .searchable was stored in an @State value on the view, or stored in a @Binding to some other location, but was not being read nor used for anything else. Is this intended as a "feature" of .searchable, that it is intentionally triggering a view update on the assumption that when the .searchable text is changed that the view will want to change? If so, this is definitely a bug in SwiftUI from the perspective of how I was wanting to use it. Alternatively, any pointers to how I might be triggering this issue would be appreciated!
0
0
148
4d
Typography on Apple Watch Live Activity
I'm not quite sure whether this post belongs in a Design forum or here, but with iOS 18 Developer Beta 1 and watchOS 11 Developer Beta 1, when a Live Activity is displayed on an Apple Watch, the system font used is SF Pro rather than SF Compact. I would expect that the design guidance would be to stick with SF Compact while on watchOS, and I would expect that the system font, when displayed on the Apple Watch using .supplementalActivityFamilies([.small]), would appear as SF Compact. To ensure that SF Compact appears on my Live Activity when viewed on Apple Watch, I can set a custom font for use with the small supplemental family, but this seems really clunky; is there any other guidance here?
0
0
101
4d
TextField set behavior request
Hello there! I come from Objective-C and there I could have an NSTextField set to not be editable or selectable: NSTextField *outputfield; [outputfield setEditable:false]; [outputfield setSelectable:false]; You can do the same in Xcode's Interface Builder panel and select options from a Picker to (Selectable, Editable or None): There is no way to achieve this in SwiftUI and the only option you have is to set a TextField() as .disabled which is not the same. I often used this setters to have an evenly looking form but where only output text (that's not meant to be edited) is show but is clearly visible. The text inside a .disabled text field has no contrast and is not clearly visible. Therefore I would like to request an addition of these two modifiers: selectable(_ selectable: Bool) editable(_ editable: Bool) I am looking forward to fully switch to SwiftUI therefore whenever I encounter something that I could do in Obj-c/Cocoa but not in SwiftUI I will evaluate and suggest it as an addition. Thanks!
2
0
85
4d
SwiftUI chart legend overflow
Using Charts in SwiftUI to create a horizontal bar chart, if the text of the legend is sufficiently long, the text overflows outside of the view rather than wrapping or moving to the next line. (can see problem when running code on on iPhone) Is this a bug or am I doing something incorrectly? I can use .clipped() to ensure the legend doesn't overflow. But that doesn't fully solve the problem because the text is then just cut off. import Charts import SwiftUI struct ChartData: Identifiable { let id: Int let title: String let count: Double let color: Color } struct ContentView: View { private let data = [ ChartData(id: 1, title: "Item 1", count: 4, color: .yellow), ChartData(id: 2, title: "Item 2 With a Long Title and then some more", count: 6, color: .blue), ChartData(id: 3, title: "Item 3 With a Long Title", count: 12, color: .green) ] private let chartHeight: CGFloat = 40 private let chartCornerRadius: CGFloat = 5 var body: some View { VStack { Chart(data) { item in BarMark( x: .value("Count", item.count), stacking: .normalized ) .foregroundStyle(by: .value("Title", item.title)) } .chartXAxis(.hidden) .chartYAxis(.hidden) .chartLegend(.visible) .chartPlotStyle { chartContent in chartContent .frame(height: chartHeight) } .chartForegroundStyleScale(range: data.map { $0.color }) } .padding() } } #Preview { ContentView() }
1
0
110
5d
Xcode previews fail with JIT error
== PREVIEW UPDATE ERROR: JITError ================================== | NoBuiltTargetDescriptionCouldBeFound | | translationUnit: PreviewTranslationUnit(moduleNamePrefix: "Previews_EmptyFeedRow", sourceIdentifier: file:///Users/bryananderson/Developer/JournalApp/JournalApp/Interface/Feed/EmptyFeedRow.swift -> EmptyFeedRow.swift, parseTree: ParseTree(version: 727, statements: 3, providers: 1), update: nil, changesContextMemoizer: PreviewsPipeline.PreviewTranslationUnit.(unknown context at $34b4b9c4c).ChangesContextMemoizer(parseTree: ParseTree(version: 727, statements: 3, providers: 1), sourceIdentifier: file:///Users/bryananderson/Developer/JournalApp/JournalApp/Interface/Feed/EmptyFeedRow.swift -> EmptyFeedRow.swift, cachedValue: os.OSAllocatedUnfairLock<Swift.Optional<PreviewsModel.ParseTree.PreviewChangesContext>>(__lock: Swift.ManagedBuffer<Swift.Optional<PreviewsModel.ParseTree.PreviewChangesContext>, __C.os_unfair_lock_s>)), registryDeclarationMemoizer: PreviewsPipeline.PreviewTranslationUnit.(unknown context at $34b4b9bec).RegistryDeclarationMemoizer) | | builtTargetDescriptions: | == VERSION INFO: Tools: 16A5171c OS: 24A5264n PID: 906 Model: MacBook Pro Arch: arm64e == ENVIRONMENT: openFiles = [ /Users/bryananderson/Developer/JournalApp/JournalApp/Interface/Feed/EmptyFeedRow.swift ] wantsNewBuildSystem = true newBuildSystemAvailable = true activeScheme = JournalApp activeRunDestination = iPhone 15 Pro variant iphonesimulator arm64 workspaceArena = [x] buildArena = [x] buildableEntries = [ Remember.app ] runMode = JIT Executor == SELECTED RUN DESTINATION: name = iPhone 15 Pro eligible = true sdk = Optional(<DVTSDK:0x13870da30:'iphonesimulator18.0':Simulator - iOS 18.0:<DVTFilePath:0x600001e8c700:'/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk'>>) variant = Optional("iphonesimulator") device = Optional(<DVTiPhoneSimulator: 0x32f00d290> { SimDevice: iPhone 15 Pro (CF3C85BC-F559-4437-9072-7F30153B399B, iOS 18.0, Booted) PairedSim: <DVTiPhoneSimulator: 0x33733d150> { SimDevice: Apple Watch Series 9 (45mm) (627CE93E-EB02-4200-BE40-3DCB5C91DB44, watchOS 11.0, Shutdown) } }) == SELECTED RUN DESTINATION: Simulator - iOS 18.0 | iphonesimulator | arm64 | iPhone 15 Pro | Apple Watch Series 9 (45mm) jit enabled: true fallback to dynamic replacement: false
2
1
103
5d
List Rows Can Be Moved While Not Editing
Hi, I am building a view containing a list of struct objects. I have implemented the onMove to allow the list rows to be moved together with the toolbar EditButton. This works but I have a problem as per title, even when the EditButton is not clicked, i.e., not in editing mode, I still can move the list rows by long pressing the rows. I have searched high and low for a solution but couldn't find one that works perfectly. Below is the code snippet. I am a new iOS dev and really appreciate if someone could help me. Many thanks! @AppStorage("fruits") private var fruits = Fruits.fruits var body: some View { NavigationStack { VStack { List { ForEach(fruits) { fruit in NavigationLink(destination: FruitsView(title: fruit.title)) { fruit.icon Text(fruit.title) } } .onMove { fruits.move(fromOffsets: $0, toOffset: $1) } } .environment(\.defaultMinListRowHeight, UIElementConstants.listCellHeight) } .toolbar { EditButton() } .navigationTitle("Fruits") } } struct Fruits: Identifiable, Codable { var id: UUID var title: String var iconName: String var icon: Image { Image(systemName: self.iconName) } init(id: UUID = UUID(), title: String, iconName: String) { self.id = id self.title = title self.iconName = iconName } } extension Fruits { static let fruits: [Fruits] = [ Fruits( title: "Apple", iconName: "basket.fill"), Fruits( title: "Banana", iconName: "basket.fill"), Fruits( title: "Pineapple", iconName: "basket.fill") ] }
2
1
119
5d
SwiftUI DropDelegate + Scrollview auto scroll while reshuffle the item outside of scrollview bounds
We have a feature requirement where we need to use LazyVGrid and DropDelegate. Our view hierarchy is as follows: Color.white.ignoresSafeArea() VStack(spacing: 0) { customNavigationView ScrollView(showsIndicators: true) { LazyVGrid(columns: columns, alignment: .center, spacing: 16) { ForEach(viewModel.selectedReferences, id: \.self) { item in ZStack { Rectangle() .fill(Color.yellow.opacity(0.5)) Text(item.title) } .frame (height: 120) .background(Color.white) .padding([.leading, .trailing], 4) .overlay((draggedItem?.uuid == item.uuid && changedView) ? Color.white.opacity(0.8) : Color.clear) .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .onDrag { initialIndex = viewModel.selectedReferences.firstIndex { $0 == item } draggedItem = item changedView = false return NSItemProvider(object: String(item.uuid) as NSString) } .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .onDrop(of: [UTType.text], delegate: DragRelocateDelegate(item: item, listData: $viewModel.selectedReferences, current: $draggedItem, changedView: $changedView) { endIndex in }) } } .animation(.default, value: viewModel.selectedReferences) } .frame(width:(UIScreen.main.bounds.width)) .onDrop(of: [UTType.text], delegate: DropOutsideDelegate(current: $draggedItem, changedView: $changedView)) bottomBarView } .frame(maxWidth: .infinity) } While performing a reshuffle, auto-scroll works within the bounds of the ScrollView content. However, according to the feature requirement, auto-scroll should also work when we place an uplifted view at the top or bottom of the view. STEPS TO REPRODUCE Launch the demo. Scroll to the bottom of the LazyVGrid. Pick any item using the DropDelegate. Try to place that uplifted view on the custom navigation view. Expected Result: The ScrollView should auto-scroll. Actual Result: Auto-scroll is not working.
0
0
92
5d