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

SwiftUI Documentation

Post

Replies

Boosts

Views

Activity

iOS 17 - TextField color does not changes with state is updated
Hi! I find this code does not work as expected on iOS 17 simulator and device. It was working correctly with iOS 16: struct ContentView: View { @State private var numberText = "" var color: Color { let result = (Int(numberText) ?? 0) <= 0 if result { return .black } return .red } var body: some View { VStack { TextField("Enter a number", text: $numberText) .font(.title) .foregroundStyle( color ) Text("Font color will turn red if number > 0") .foregroundColor(.gray) } .padding() } } I tried a workaround and it works: struct ContentView: View { @State private var numberText = "" @State private var color = Color.black func updateColor() ->Color { let result = (Int(numberText) ?? 0) <= 0 if result { return .black } return .red } var body: some View { VStack { TextField("Enter a number", text: $numberText) .font(.title) .foregroundStyle( color ) .onChange(of:numberText) { color = updateColor() } Text("Font color will turn red if number > 0") .foregroundColor(.gray) } .padding() } }
6
1
1.3k
Oct ’23
SwiftUI BottomBar Toolbar on parent view breaks leading navigation swipe on iOS 17.0
After Updating my app to iOS 17.0 I noticed some odd behavior when swiping a detail view away with a parent view that has a toolbar with a ToolbarItem(placement: .bottomBar). As the user starts a leading swipe gesture to navigate back to the previous view the parent navigation title strangely animates to the center and the leading nav bar button disappears. If the user stops this gesture at any point before completing the swipe they will be stuck in the detail view as the leading nav button has disappeared. This only seems to be an issue if one attempts to swipe back to the parent view and not when the leading nav button is tapped. The following is the minimum code to reproduce this issue for me. I am testing on a physical device on iOS 17.0 with Xcode Version 15.0 (15A240d). struct ToolbarIssueView: View { var body: some View { NavigationStack { NavigationLink { Text("Detail View") .navigationTitle("Detail") } label: { Text("To Detail View") } .toolbar { // This seems to cause strange behavior ToolbarItem(placement: .bottomBar) { Text("Bottom Bar Content") } } .navigationTitle("Main") } } } I understand that this bottom bar could easily be replaced with a .safeAreaInset(edges: .bottom) but I would prefer to use the more standard ToolbarItem(placement: .bottomBar). If anyone has any fixes for this issue or know what I am missing I would love to hear it!
9
9
3.9k
Oct ’23
SwiftUI Sheet never releases object from memory on iOS 17
I've found a very strange behaviour which looks like a bug. SwiftUI sheet or fullScreenCover do not release objects that were passed to its item: parameter (and to the view builder body by the way, but here is the simplified case). It works well and memory is releasing on iOS 16 built with both Xcode 14 or 15. (simulators, devices) Memory is leaking and NOT releasing on iOS 17 built with Xcode 15. (simulator, device 17.0.2) Any ideas how we can solve this or we have to wait for the bugfix? This is going to be a global memory leak, I am sure most of SwiftUI apps are using classes passed to the sheet or fullScreenCover. struct SheetView: View { @State var sheetVM: SheetVM? var body: some View { Button { sheetVM = .init() } label: { Text("Navigate") } .sheet(item: $sheetVM) { sheetVM in Color.yellow } } } final class SheetVM: ObservableObject, Identifiable { @Published var title: String = "Title" init() { print("SheetVM init") } deinit { print("... SheetVM deinit") } } struct SheetView_Previews: PreviewProvider { static var previews: some View { SheetView() } }
9
7
3.1k
Oct ’23
App freezes when tapping a navigation link
I have two main models, House and Expense. On the home page I show a list of the three most recent expenses using the following query: var descriptor = FetchDescriptor<Expense>(predicate: #Predicate { $0.houseID == house.id }, sortBy: [SortDescriptor(\.date, order: .reverse)]) descriptor.fetchLimit = 3 _recentExpenses = Query(descriptor) I have a NavigationLink that takes you to the full list of expenses: NavigationLink { ExpenseListView(house: house) } label: { Text("See all") } On this page I have a query similar to the previous one, without the fetch limit: let descriptor = FetchDescriptor<Expense>( predicate: #Predicate { $0.houseID == house.id} ) _expenses = Query(descriptor) The problem is that when I click on the navigation link to go to the expenses page, the app freezes. I tried passing the expenses array to the second page instead of invoking another query, but this way the view doesn't update when I update the expenses. Is there a way to solve this problem? Or a way to pass a Binding of the fetched results?
4
1
873
Oct ’23
SwiftData: "Illegal attempt to establish a relationship 'item' between objects in different contexts
I have run into this SwiftData issue in multiple projects and have been able to replicate it by building off of the default SwiftData launch project. The original Item class: class Item { var timestamp: Date init(timestamp: Date) { self.timestamp = timestamp } } New MyItem class to replicate the error. Notice I nest an Item object inside MyItem: class MyItem { var name: String var item: Item init(name: String, item: Item) { self.name = name self.item = item } } I then build off of the default view for a SwiftData project. When the '+' button is pressed, a new list item for both Item and MyItem should appear in their appropriate sections. @Environment(\.modelContext) private var modelContext @Query private var items: [Item] @Query private var myItems: [MyItem] var body: some View { NavigationSplitView { List { Section("All Items") { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } } Section("My Items") { ForEach(myItems) { myItem in NavigationLink { Text("Item at \(myItem.item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { HStack { Text(myItem.name) Spacer() Text(myItem.item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } } } } .toolbar { ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } } detail: { Text("Select an item") } } private func addItem() { withAnimation { let newItem = Item(timestamp: Date()) modelContext.insert(newItem) let newMyItem = MyItem(name: "Test", item: newItem) modelContext.insert(newMyItem) } } } The app crashes and I get the following error when I attempt to click the '+' button (which should create a new Item and MyItem in the modelContext: Thread 1: "Illegal attempt to establish a relationship 'item' between objects in different contexts (source = <NSManagedObject: 0x600002166940> (entity: MyItem; id: 0x600000298240 x-coredata:///MyItem/t2D4951EB-0D2F-44B1-AF8C-5A1BB11659F53; data: {\n item = nil;\n name = Test;\n}) , destination = <NSManagedObject: 0x600002174000> (entity: Item; id: 0x600000232440 x-coredata:///Item/t2D4951EB-0D2F-44B1-AF8C-5A1BB11659F52; data: {\n timestamp = "2023-10-04 18:21:21 +0000";\n}))" Can anyone help me understand the new SwiftData framework in this regard? I am still new to SwiftUI.
10
3
2.5k
Oct ’23
SwiftUI iOS 17 White screen when I return back with Navigation Stack
When using the Navigation Stack with paths, I've faced an issue where tapping the 'back' button on the custom navigation bar results in a blank screen. With light theme the screen is white, when using dark theme the screen is black. I've found a decision with using an environment value to dismiss a single screen when needed. However, the problem becomes more prominent when I want to pop back to the root view. This issue has become since updating to iOS 17.
2
3
1.5k
Oct ’23
NavigationLinks embedded in a List getting clipped in tvOS
I want to recreate an user experience like in the settings app in tvOS. Therefore I have a HStack with some content on the left side and a List of NavigationLinks on the right side. However a focused link in the list gets clipped on the left side. I tried paddings and spacers and what not, but nothing helped. Is this is a bug or am I missing something? Here is some example code to show the problem: struct ContentView: View { var body: some View { NavigationStack { HStack(spacing: 20) { VStack(alignment: .center) { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } List { ForEach(SomeViewEnum.allCases) { someView in NavigationLink(someView.rawValue, value: someView) } } .navigationDestination(for: SomeViewEnum.self) { someView in Text(someView.rawValue) } } } } } And a screenshot to show the problem:
1
1
578
Oct ’23
Problem with TextFields and decimals iOS17
After upgrading to iOS 17 I am struggling to get decimals working in my app - here is a sample code: for clarity I provide a complete "working" sample (I am pulling data from a back-end server using json, etc - all of that is working ok, it's the UI issue - see below): Model import Foundation struct TestFloat: Encodable { var testFloatNumber: Float = 0 } Observable Class import Foundation class TestFloatViewModel: ObservableObject { @Published var testFloat = TestFloat() } View struct TestFloatView: View { @ObservedObject var testFloatVM: TestFloatViewModel let formatter: NumberFormatter = { let formatter = NumberFormatter() formatter.numberStyle = .decimal return formatter }() var body: some View { VStack { HStack { Text("Enter Float Number") Spacer() } Spacer() .frame(height: 2.0) HStack { TextField("Enter Float Number", value: $testFloatVM.testFloat.testFloatNumber, formatter: formatter) .keyboardType(.decimalPad) .textFieldStyle(.roundedBorder) } } } } This is working on a device with iOS16; however when run on device with iOS17: you can enter maximum four digits? using backspace you can delete all numbers apart of the first one you cannot enter the decimal (.) at all even though decimal keyboard is provided Any help is greatly appreciated.
10
3
1.7k
Oct ’23
@Environment for new @Observable macro not creating bindings?
Hi guys, I am trying to use the new @Observable macro. According to the documentation, this new macro will automatically generate observable properties, but I am having issues using my properties when Bindings are necessary. Previously I had a setup like this: class Example: ObservableObject { @Published public var myArray = [CustomType]() } I initialised one instance of the Example-class in @main @StateObject private var exampleClass = Example() And added as an .environmentObject onto the root view ContentView() .environmentObject(exampleClass) In child views I was able to access the @Published property as a binding via @EnvironmentObject private var example: Example $example.myArray What I am trying now This is the setup that I am trying with now: @Observable class Example { public var myArray = [CustomType]() } State instead of StateObject in @main @State private var exampleClass = Example() .environment instead of .environmentObject ContentView() .environmentObject(exampleClass) @Environment instead of @EnvironmentObject @Environment(Example.self) private var example This new setup is not letting me access $example.myArray. Is this intended? Could someone explain why?
2
2
924
Oct ’23
Infinite loop getting "_dismiss changed"
I'm working on a NavigationStack based app. Somewhere I'm using: @Environment(\.dismiss) private var dismiss and when trying to navigate to that view it gets stuck. I used Self._printChanges() and discovered the environment variable dismiss is changing repeatedly. Obviously I am not changing that variable explicitly. I wasn't able to reproduce this in a small project so far, but does anybody have any idea what kind of thing I could be doing that might be causing this issue? iOS 17.0.3
7
3
1.4k
Oct ’23
ShareLink not reliable, entitlement errors
I am using public struct ShareLink<Data, PreviewImage, PreviewIcon, Label> : View where Data : RandomAccessCollection, PreviewImage : Transferable, PreviewIcon : Transferable, Label : View, Data.Element : Transferable {} And it is generating entitlement errors and not working reliably ( will transfer 1-3 items, but not 4+ ; will not work a second time) Error is: Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "(originator doesn't have entitlement com.apple.runningboard.primitiveattribute AND originator doesn't have entitlement com.apple.runningboard.assertions.frontboard AND target is not running or doesn't have entitlement com.apple.runningboard.trustedtarget AND Target not hosted by originator)" UserInfo={NSLocalizedFailureReason=(originator doesn't have entitlement com.apple.runningboard.primitiveattribute AND originator doesn't have entitlement com.apple.runningboard.assertions.frontboard AND target is not running or doesn't have entitlement com.apple.runningboard.trustedtarget AND Target not hosted by originator)}> Received port for identifier response: <> with error:Error Domain=RBSServiceErrorDomain Code=1 "Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state, NSLocalizedFailureReason=Client not entitled, RBSPermanent=false} elapsedCPUTimeForFrontBoard couldn't generate a task port Received port for identifier response: <> with error:Error Domain=RBSServiceErrorDomain Code=1 "Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state, NSLocalizedFailureReason=Client not entitled, RBSPermanent=false} elapsedCPUTimeForFrontBoard couldn't generate a task port Received port for identifier response: <> with error:Error Domain=RBSServiceErrorDomain Code=1 "Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state, NSLocalizedFailureReason=Client not entitled, RBSPermanent=false} Code is import SwiftUI var images = Array<Image?>(repeating: nil , count: 200); struct ShareTestGContentView: View { let columns = [GridItem(.fixed(165)), GridItem(.fixed(165))] private let twoColumnGrid = [ GridItem(.flexible(minimum: 40), spacing: 2), GridItem(.flexible(minimum: 40), spacing: 2) ] @State var selected = Set() var body: some View { topSection() ScrollView { LazyVGrid(columns: twoColumnGrid, spacing: 2) { // columns: [GridItem(.flexible())]) { ForEach(1...100, id: \.self) { idx in var cr = ( selected.contains(idx) ? 16.0 : 0 ) var lw = ( selected.contains(idx) ? 8.0 : 0 ) VStack{ Button(action: { if selected.contains(idx) { selected.remove(idx); cr = 0.0; lw = 0.0 } else { selected.insert(idx); cr = 16.0; lw = 8.0 } } , label: { AsyncImage(url :URL(string: "https://picsum.photos/800/800?\(idx)")) { image in let _ = ( images[idx] = image.image ) image.image }.frame(width: boxHalf,height:boxHalf).drawingGroup() }) }.overlay( RoundedRectangle(cornerRadius: cr).stroke(Color.yellow, lineWidth: lw) ).drawingGroup() } } } } func topSection() -> some View { let imgarray = selected.compactMap { images[$0] } return HStack { ShareLink("",items: imgarray) { img in SharePreview("images", image: Image(systemName: "captions.bubble.fill")) } } } } #Preview { ShareTestGContentView() }
6
9
4.9k
Oct ’23
MapKit elevation information for a route
Hello all, I am playing with MapKit for SwiftUI, so far so good. There is one thing I have not seen any documentations, or sample codes around and that's elevation data, e.g. My questions are: Is there a way to get this information from an MKRoute? Is it possible to get the elevation gain/drop at a given point in the route? Many thank in advance for your help.
1
1
470
Oct ’23
Xcode 15 iOS 17 Failed to install app on the device
Hi all, I've spent 3 of my 'coding-time' sessions already on trying to figure this one out. But I wasn't successful. I'm a hobby dev, so not too experienced with signing of anything code-wise. So time to head to the forums for help. My SwiftUI app runs fine on the simulator. My app also runs fine when downloaded from the store. But I cannot: Build the item from Xcode to my new iPhone 15 Build and distribute an archive, so that I can release a new version of my app What I did so far: Removed and reinstalled my Pods via Terminal Removed and reinstalled my packages through Xcode Removed trusted devices from my iPhone Removed trusted devices from my Macbook Added my new iPhone to my Apple Developer account via https://developer.apple.com/account/resources/devices/list Removed my old iPhone Restarted everything at least 5 times I keep getting this error after building, but immediately upon installing: Failed to install the app on the device. Domain: com.apple.dt.CoreDeviceError Code: 3002 User Info: { DVTErrorCreationDateKey = "2023-10-16 11:47:42 +0000"; IDERunOperationFailingWorker = IDEInstallCoreDeviceWorker; NSURL = "file:///Users/jorritgernaat/Library/Developer/Xcode/DerivedData/WalkApp-fukevcszpwufbzavuluhlbvhsaaa/Build/Products/Debug-iphoneos/WalkApp.app/"; } -- Paaltjesroutes moet worden bijgewerkt Domain: IXUserPresentableErrorDomain Code: 17 Failure Reason: Deze app moet door de ontwikkelaar worden bijgewerkt om te kunnen werken met deze iOS-versie. Recovery Suggestion: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.UleUN5/extracted/WalkApp.app/Frameworks/FirebaseFirestore.framework : 0xe8008029 (The code signature version is no longer supported.) -- Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.UleUN5/extracted/WalkApp.app/Frameworks/FirebaseFirestore.framework : 0xe8008029 (The code signature version is no longer supported.) Domain: MIInstallerErrorDomain Code: 13 User Info: { FunctionName = "+[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]"; LegacyErrorString = ApplicationVerificationFailed; LibMISErrorNumber = "-402620375"; SourceFileLine = 78; } -- Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : { "device_isCoreDevice" = 1; "device_model" = "iPhone15,4"; "device_osBuild" = "17.0.3 (21A360)"; "device_platform" = "com.apple.platform.iphoneos"; "dvt_coredevice_version" = "348.1"; "dvt_mobiledevice_version" = "1643.2.4"; "launchSession_schemeCommand" = Run; "launchSession_state" = 1; "launchSession_targetArch" = arm64; "operation_duration_ms" = 1864; "operation_errorCode" = 17; "operation_errorDomain" = "com.apple.dt.CoreDeviceError.3002.IXUserPresentableErrorDomain"; "operation_errorWorker" = IDEInstallCoreDeviceWorker; "operation_name" = IDERunOperationWorkerGroup; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.iphoneos"; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_tpc_enable" = 1; "param_diag_gpu_frameCapture_enable" = 0; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 1; "param_install_style" = 0; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 99; "param_launcher_substyle" = 8192; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.application"; "param_structuredConsoleMode" = 1; "param_testing_launchedForTesting" = 0; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "iphoneos17.0"; "sdk_osVersion" = "17.0"; "sdk_variant" = iphoneos; } -- System Information macOS Version 14.0 (Build 23A344) Xcode 15.0 (22265) (Build 15A240d) Timestamp: 2023-10-16T13:47:42+02:00``` It seems to somehow involve Firebase, but that can also be because that's simply the only 3rd party stuff I use. Help me get back to writing code and shipping app updates :)
8
0
19k
Oct ’23
@Observable is being re-init every time view is modified
I am surprised at what I am seeing with the new @Observable framework in iOS 17. It seems that if the view containing the @State var, ie viewModel, is modified, then the init of that viewModel will also be called. This is not the behavior of the prior StateObject method of using a viewModel. As I understand the @State should not be reinitialized on redrawing on the View, is this the expected behavior? Example: struct ContentView: View { @State var offset = false var body: some View { VStack { InnerView() .offset(x: offset ? 200 : 0) Button("Offset") { offset.toggle() } } } } // iOS 17 Observable method: struct InnerView: View { @State var viewModel: ViewModel init() { self._viewModel = State(wrappedValue: ViewModel()) } var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } } @Observable class ViewModel { init() { print("ViewModel Init") } } // StateObject method: struct InnerView: View { @StateObject var viewModel: ViewModel init() { self._viewModel = StateObject(wrappedValue: ViewModel()) } var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } } class ViewModel: ObservableObject { init() { print("ViewModel Init") } }
2
1
950
Oct ’23
Xcode 15 Preview not working with generic nested view
It seem that Xcode preview compiler fail correctly parse generic and produce a "Failed to build" error: Proposed example: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ import CoreBluetooth import SwiftUI /// Working in preview /* struct InitialView&lt;S&gt;: View where S: StringProtocol { var body: some View { NestedView() } struct NestedView: View { var body: some View { Text("Hello") } } } struct WorkingView: View { var body: some View { InitialView&lt;String&gt;() } } */ /// Not working in preview struct NotWorking: View { var body: some View { InitialView&lt;String&gt;() } struct InitialView&lt;S&gt;: View where S: StringProtocol { var body: some View { NestedView() } struct NestedView: View { var body: some View { Text("Hello") } } } } struct ContentView_PreviewProviders: PreviewProvider { static var previews: some View { NotWorking() } } ^^^^^^^^^^^^^^^^^^^^^^^^^^^ investigating the SampleView.1.preview-thunk.swift from ~/Library/Developer/Xcode/DerivedData/.../ directory, I found that compiler translate the above code into pre-compiled stage using typealias without considering the Generic condition- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... extension NotWorking.InitialView.NestedView { typealias InitialView = NotWorking.InitialView typealias NestedView = NotWorking.InitialView.NestedView @_dynamicReplacement(for: body) private var __preview__body: some View { #sourceLocation(file: "/Users/giuseppe/Development/Private/Dev/MyPlayground/MyPlayground/SampleView.swift", line: 40) Text(__designTimeString("#32812.[2].[1].[1].[0].property.[0].[0].arg[0].value", fallback: "Hello")) #sourceLocation() } } extension NotWorking.InitialView { typealias InitialView = NotWorking.InitialView typealias NestedView = NotWorking.InitialView.NestedView @_dynamicReplacement(for: body) private var __preview__body: some View { #sourceLocation(file: "/Users/giuseppe/Development/Private/Dev/MyPlayground/MyPlayground/SampleView.swift", line: 35) NestedView() #sourceLocation() } } extension NotWorking { @_dynamicReplacement(for: body) private var __preview__body: some View { #sourceLocation(file: "/Users/giuseppe/Development/Private/Dev/MyPlayground/MyPlayground/SampleView.swift", line: 30) InitialView&lt;String&gt;() #sourceLocation() } } ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Should be considered a compiler bug or I missed something in my code?
7
0
1.4k
Oct ’23
Opening SwiftUI Settings from AppKit
I have an app that uses AppKit and SwiftUI. The app settings are made with SwiftUI On macOS 13 you could use the following to open SwiftUI settings: NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) On macOS 14 Sonoma the above does not work anymore, instead you have to use a SwiftUI View called SettingsLink. Now the problem is, my app needs to open Settings from a part of the app that uses AppKit. My app does not show or use its menubar, so Settings are not accessible from there, so I provide access from a NSMenuItem. How can I programmatically open SwiftUI Settings from AppKit?
3
2
888
Oct ’23
macOS SwiftUI Table Performance Issue
Has anyone else created a macOS SwiftUI app that uses a Table with a largish (~1000) number of entries? My app works OK at about 100 entries, but slows down as the number of entries increase. How slow? An instrumented test with 1219 entries shows a Hang of over 13 seconds from simply clicking/selecting an item in the table. Instruments says the time is mostly spent in _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION. Digging deeper I see AG::Subgraph::update(unsigned int) and descendants account for about half of the hang time. My app is using @Observable on macOS 14 and is being tested on an M2 Max Studio. There are other reported hangs. All seem to be in Swift/SwiftUI code.
6
1
1.7k
Oct ’23
How to Change Picker Text Color In SwiftUI
I try to change picker text color but, it does not work. As you see, "City" and "District"'s color are blue but, I'd like to make them white. I have tried below codes but, they do not work. Do you know any methods for that ? Picker("İl", selection: $selectedCity) { ForEach(turkishCities, id: \.self) { city in Text(city) .foregroundColor(.white) } } Picker("İlçe", selection: $selectedDistrict) { ForEach(cityDistricts[selectedCity] ?? [], id: \.self) { district in Text(district) .foregroundColor(Color.white) } } .onAppear { UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor: UIColor.white], for: .normal) } Thank you in advance.
3
0
6.2k
Oct ’23