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

SwiftUI Documentation

Posts under SwiftUI subtopic

Post

Replies

Boosts

Views

Activity

Combining NavigationSplitView and TabView in iOS 18
Hi folks, I've used a NavigationSplitView within one of the tabs of my app since iOS 16, but with the new styling in iOS 18 the toolbar region looks odd. In other tabs using e.g. simple stacks, the toolbar buttons are horizontally in line with the new tab picker, but with NavigationSplitView, the toolbar leaves a lot of empty space at the top (see below). Is there anything I can do to adjust this, or alternatively, continue to use the old style? Thanks!
11
3
2.6k
Jul ’24
iOS 18 beta bug: NavigationStack pushes the same view twice
Hello, community and Apple engineers. I need your help. Our app has the following issue: NavigationStack pushes a view twice if the NavigationStack is inside TabView and NavigationStack uses a navigation path of custom Hashable elements. Our app works with issues in Xcode 18 Beta 13 + iOS 18.0. The same issue happened on previous beta versions of Xcode 18. The issue isn’t represented in iOS 17.x and everything worked well before iOS 18.0 beta releases. I was able to represent the same issue in a clear project with two simple views. I will paste the code below. Several notes: We use a centralised routing system in our app where all possible routes for navigation path are implemented in a View extension called withAppRouter(). We have a enum RouterDestination that contains all possible routes and is resolved in withAppRouter() extension. We use Router class that contains @Published var path: [RouterDestination] = [] and this @Published property is bound to NavigationStack. In the real app, we need to have an access to this path property for programmatic navigation purposes. Our app uses @ObservableObject / @StateObject approach. import SwiftUI struct ContentView: View { @StateObject private var router = Router() var body: some View { TabView { NavigationStack(path: $router.path) { NavigationLink(value: RouterDestination.next, label: { Label("Next", systemImage: "plus.circle.fill") }) .withAppRouter() } } } } enum RouterDestination: Hashable { case next } struct SecondView: View { var body: some View { Text("Screen 2") } } class Router: ObservableObject { @Published var path: [RouterDestination] = [] } extension View { func withAppRouter() -> some View { navigationDestination(for: RouterDestination.self) { destination in switch destination { case .next: return SecondView() } } } } Below you can see the GIF with the issue: What I tried to do: Use iOS 17+ @Observable approach. It didn’t help. Using @State var path: [RouterDestination] = [] directly inside View seems to help. But it is not what we want as we need this property to be @Published and located inside Router class where we can get an access to it, and use for programmatic navigation if needed. I ask Apple engineers to help with that, please, and if it is a bug of iOS 18 beta, then please fix it in the next versions of iOS 18.0
12
4
1.8k
Jul ’24
SwiftUI Gestures prevent scrolling with iOS 18
I added gesture support to my app that supports iOS 16 and 17 and have never had issues with it. However, when I compiled my app with Xcode 16 I immediately noticed a problem with the app when I ran it in the simulator. I couldn't scroll up or down. I figured out it’s because of my gesture support. My gesture support is pretty simple. let myDragGesture = DragGesture() .onChanged { gesture in self.offset = gesture.translation } .onEnded { _ in if self.offset.width > threshold { ...some logic } else if self.offset.width < -threshold { ...some other logic } logitUI.debug("drag gesture width was \(self.offset.width)") self.offset = .zero } If I pass nil to .gesture instead of myDragGesture then scrolling starts working again. Here’s some example output when I’m trying to scroll down. These messages do NOT appear when I run my app on an iOS 16/17 simulator with Xcode 15. drag gesture width was 5.333328 drag gesture width was -15.333344 drag gesture width was -3.000000 drag gesture width was -24.333328 drag gesture width was -30.666656 I opened FB14205678 about this.
17
21
9.7k
Jul ’24
onContinueUserActivity(CSSearchableItemActionType, perform) does not work on a SwiftUI macOS app
onContinueUserActivity(CSSearchableItemActionType, perform) works as expected on iOS when we search and select an item from Spotlight, but nothing happens when we do the same on a SwiftUI macOS app. var body: some Scene { WindowGroup { MyView() .onContinueUserActivity(CSSearchableItemActionType, perform: handleSpotlight) } } func handleSpotlight(_ userActivity: NSUserActivity) { // Is not called... } How can we respond to a user clicking a Spotlight result from our apps on macOS?
2
1
764
Jul ’24
.highPriorityGesture causes ScrollView to be unable to scroll
This problem will occur in Xcode 16 beta and iOS 18 beta, are there any changes to the function of highPriorityGesture in iOS 18? Example code is: import SwiftUI struct ContentView: View { @State private var dragable: Bool = false @State private var dragGestureOffset: CGFloat = 0 var body: some View { ZStack { ScrollViewReader { scrollViewProxy in ScrollView(showsIndicators: false) { cardList .padding(.horizontal, 25) } } } .highPriorityGesture(dragOffset) } var cardList: some View { LazyVStack(spacing: 16) { Text("\(dragGestureOffset)") .frame(maxWidth: .infinity) .padding(.vertical,8) .background { RoundedRectangle(cornerRadius: 8) .fill(.gray) } //Display 100 numerical values in a loop ForEach(0..<100) { index in Text("\(index)") .frame(maxWidth: .infinity) .padding(.vertical,8) .background { RoundedRectangle(cornerRadius: 8) .fill(.gray) } } } } var dragOffset: some Gesture { DragGesture() .onChanged { value in if abs(value.translation.width) > 25 { dragable = true dragGestureOffset = value.translation.width } } .onEnded { value in if abs(value.translation.width) > 25 { dragable = false dragGestureOffset = 0 } } } }
2
3
1.2k
Jul ’24
@Observable state class reinitializes every time view is updated
With the new @Observable macro, it looks like every time the struct of a view is reinitialized, any observable class marked as @State in the struct also gets reinitialized. Moreover, the result of the reinitialization immediately gets discarded. This is in contrast to @StateObject and ObservableObject, where the class would only be initialized at the first creation of the view. The initialization method of the class would never be called again between view updates. Is this a bug or an expected behavior? This redundant reinitialization causes performance issues when the init method of the observable class does anything slightly heavyweight. Feedback ID: FB13697724
3
1
928
Jul ’24
.alignmentGuide modifier causes consistent app crash when Swift 6 language mode is enabled
I've been experiencing random crashes in my app and today, I could finally narrow it down enough to start building an example project that consistently crashes. The error is this: "com.apple.SwiftUI.AsyncRenderer (19): EXC_BREAKPOINT (code=1, subcode=0x102f103f8)" It's a very strange bug because the SwiftUI view hierarchy has to be in a very specific shape to cause the crash, but if it is, then it crashes 100% of the time: It's a button inside a List and a simple "@State var number: Int?" that is being animated when the view appears. You can simply paste the following code into a project and run it (device, simulator or even in a preview): // Must be in Swift 6 Language Mode! // iOS 18 Beta 4 struct ContentView: View { @State var number: Int? var body: some View { List { // Must be in a List // It also crashes if button is here inside the List } .overlay { button } .task { // Has to be in a task modifier (or .onAppear + Task {}, so it has to be async) number = 0 } } // Has to be in a separate view property private var button: some View { Button {} label: { // Has to be this initializer and not Button(number == nil ? "" : "") {} if number == nil { // There has to be a conditional with "number" in here Color.clear } } .animation(.default, value: number) // Animation must be inside the List .alignmentGuide(VerticalAlignment.center) { dimension in dimension[VerticalAlignment.center] } } } The crash only happens under the following conditions, as far as I can tell: This only happens in the Swift 6 language mode (which I have enabled in the example project) It's related to an .alignmentGuide modifier attached to a button that also has an .animation modifier The button has to have a conditional view inside its label that checks for the same variable that is being animated The button must be inside a separate property that is put either inside a List or inside an overlay of a List The crash is then triggered when the animated value is asynchronously changed (in a .task modifier for example) The crash happens at least with Beta 3 and 4 of Xcode 16.0 I have also opened a feedback: FB14510236 but I thought I'd post it here as well because this crash was driving me crazy and maybe others might find it helpful for their debugging. Took me hours to find out what's been causing it 😅 Edit: Interestingly, when I run this project on an iOS 17 device, it does not crash, but rather print a runtime warning: "warning: data race detected: @MainActor function at AlignmentGuideCrash/ContentView.swift:27 was not called on the main thread" Line 27 is: .alignmentGuide(VerticalAlignment.center) { dimension in
6
1
991
Jul ’24
Can’t focus the sidebar on tvOS when TabView contains TabSection elements
In a TabView with the .sidebarAdaptable style, including TabSection elements prevents the default back swipe on the remote from revealing the sidebar. Removing all TabSection elements and using only Tab elements makes it work as expected: import SwiftUI struct ContentView: View { var body: some View { TabView { Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } TabSection("Section") { Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } } } }.tabViewStyle(.sidebarAdaptable) } } Am I using it wrong, or is this a bug?
3
2
782
Jul ’24
What is a performant way to change view offset as user scrolls?
I added a background view to my SwiftUI List, and would like to move it up as user scrolls (similar to the effect of that of the Health app). I can't add it onto the background of a List row, because List unconditionally clips content to a row, and I would like the view to extend past a insetted row's bounds (scrollClipDisabled does not work on List). So I added the view as the background view of the entire List. Currently, I am achieving this by monitoring contentOffset using the new onScrollGeometryChange(for:of:action:) modifier, updating a state variable that controls the offset of the background view. The code looks something like this: struct ContentView: View { @State private var backgroundOffset: CGFloat = 0 var body: some View { List { ... } .background { backgroundView .offset(y: backgroundOffset) } .onScrollGeometryChange(for: ScrollGeometry.self) { geometry in geometry } action: { oldValue, newValue in let contentOffsetY = newValue.contentOffset.y let contentInsetY = newValue.contentInsets.top if contentOffsetY <= -contentInsetY { backgroundOffset = 0 } else { backgroundOffset = -(contentOffsetY + contentInsetY) } } } } However, this results in bad scrolling performance. I am guessing this is due to backgroundOffset being updated too frequently, and thus refreshing the views too often? If so, what is a more performant approach to achieve the desired effect? Thanks!
3
0
868
Aug ’24
Access Environment values through PresentationDetents.Context
I want to create a custom presentation detent to set a custom height for a sheet presentation. For that, I added a struct conforming to CustomPresentationDetent which has an only method static function height(in: Self.Context) -> CGFloat?. Implementation works fine, the view presented inside the sheet modifier has the height returned by the custom detent. The problem comes when I try to access the Context's environment values inside the protocol conformance method. PresentationDetent.Context has a subscript that enables accessing any environment value subscript<T>(dynamicMember _: KeyPath<EnvironmentValues, T>) -> T but using it from the custom detents height method only returns the default value for each one. I'm trying to set the environment values through environment<V>(WritableKeyPath<EnvironmentValues, V>, V) modifier but it does not seem to work. When accessed via @Environment property wrapper from the view it does get the updated value though. Is there any other way to set an environment value or any special way to set it so that it is visible from a presentation detent?
Topic: UI Frameworks SubTopic: SwiftUI
5
1
413
Aug ’24
SwiftData on iOS 18 extreme memory use
Hi, I've run into two problems using SwiftData in iOS 18 that are total show-stoppers for my app, causing it to run out of memory and be killed by the system. The same app runs fine on iOS 17. The two problems are inter-related in a way I can't exactly diagnose, but are easy to reproduce. Problem #1: Calling .count on the array that represents a relationship or Query causes the whole array of objects to be loaded into memory. Problem #2: When a @Model object is loaded, properties that are declared with .externalStorage are loaded unnecessarily, and use tons of memory. It's possible that #1 is normal behavior, exacerbated by #2. I've written a test app that demonstrates the extreme difference in memory usage between the OS Versions. It uses a typical navigation pattern, with content counts on the left-side view. Each item has one thumbnail and one large image in .externalStorge. GitHub Source When populated with 80 items, each containing one thumbnail and one large image in .externalStorge, the app launches in 17.5 using 29mb of memory. On iOS 18, in the same conditions, 592 mb. When the first folder is selected, causing a list of thumbnails to load, iOS 17 uses just 86mb. iOS 18 uses 599mb, implying that all image data has already been loaded. So I'm asking for help from Apple or the Community in finding a workaround. I've been advised that finding a workaround may be necessary, as this may not be addressed in 18.0. Thanks in advance for any insight. Radars: FB14323833, FB14323934 (See attached images, or try it yourself) (You may notice in the 18.0 screenshots that the item counts don't add up right. That's yet another 18.0-SwiftData anomaly regarding relationships that I haven't tackled yet, but is also demonstrated by the sample app.)
14
5
3.5k
Aug ’24
Frequent Crash on Table Content Change
One of my apps has been crashing on multiple Sequoia betas, something that never happened on prior macOS versions, and I’ve finally narrowed it down to a smaller reproducible case which I've attached to bug report #FB14473269. The narrowed case is fairly trivial. A table containing data is filtered by typing into a text field which narrows the bound content by finding only text with matching substrings. It's a single basic view the source for which is included in its entirety below. To reproduce the crash: Compile and run Type “five” in the search text If this doesn’t immediately crash it with the first keystroke (there seems to be some kind of race condition so it may vary on different hardware configurations), delete a character at a time and repeat as necessary. Typing “one” on my system doesn’t crash the app, but deleting backwards to just “o” immediately crashes. The backtrace is entirely within SwiftUI. This works flawlessly on Sonoma which is where I've been building and testing the app where this problem was first discovered, and it's completely unusable up through beta 5 of Sequoia. It's hard to believe nobody else is encountering this. Any suggestions? import SwiftUI class Item: Identifiable { var id: String init(_ id: String) { self.id = id } } struct ContentView: View { @State var allItems = [ Item("One"), Item("Two"), Item("Three"), Item("Four"), Item("Five"), Item("Six"), Item("Seven"), Item("Eight"), Item("Nine"), Item("Ten") ] @State var filteredItems = [Item]() @State var selectedItems = Set<Item.ID>() @State var text: String = "" func filter() { if text == "" { filteredItems = allItems } else { filteredItems = allItems.filter { $0.id.localizedCaseInsensitiveContains(text) } } } var body: some View { VStack { TextField("Search:", text: $text) .padding() .onChange(of: text) { filter() } .onAppear { filter() } Table($filteredItems, selection: $selectedItems) { TableColumn("Name") { item in Text(item.id) } } } } } #Preview { ContentView() }
8
1
807
Aug ’24
There seems to be a bug with digitalCrownAccessory
After reading the documentation on .digitalCrownAccessory, I am under the impression that the system should know to show your accessory and hide your accessory according to whether the crown is being rotated. I have noticed this is not the case. I have also tried a few work arounds with no luck. Here is a simplified version of my code. I have recorded a video of the issue I am seeing, but I can't upload it, so I have attached some screenshots instead. Expected result: After rotating the crown, the accessory image should disappear along with the vertical system scroll bar. Actual result: After rotating the crown, the vertical system scroll bar disappears but the accessory image stays behind. Versions: Sonoma 14.6.1 Xcode 16 Beta 5 (and Xcode 15.4) Apple Watch Ultra 2 watchOS 11 (device and simulator) Starting file (main): import SwiftUI @main struct DummyWatch_Watch_AppApp: App { var body: some Scene { WindowGroup { ContentView() } } } ContentView.swift: import SwiftUI struct ContentView: View { @State var crownValue: CGFloat = 0 var body: some View { VStack { Text("Hello, world!") } .focusable() .digitalCrownRotation($crownValue, from: 0, through: 10, by: 0.1, sensitivity: .low, isContinuous: false) .digitalCrownAccessory { Image(systemName: "speaker.fill") } .padding() } } Images: Scrolling: Speaker wont go away:
1
1
507
Aug ’24
LongPressGesture.updating(_:body:)
Hello, I'm using LongPressGesture to provide haptic & color change feedback on a long press action. This fails to call the .updating(_:body:) method on every iOS 18.0 beta. It works fine on iOS 17. The following code, taken directly from Apple's documentation illustrates the problem. The .updating() closure is never called, while the .onEnded() closure is called correctly. Instead of a gradual color transition the example code generates a delayed sharp switch from Red to Blue, preventing interactive user feedback. struct LongPressGestureView: View { @GestureState private var isDetectingLongPress = false @State private var completedLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 3) .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState transaction.animation = Animation.easeIn(duration: 2.0) } .onEnded { finished in self.completedLongPress = finished } } var body: some View { Circle() .fill(self.isDetectingLongPress ? Color.red : (self.completedLongPress ? Color.green : Color.blue)) .frame(width: 100, height: 100, alignment: .center) .gesture(longPress) } } Can anyone share tips on a workaround or potential fix application-side?
4
4
1.1k
Aug ’24
Can SwiftUI View Receive a Call When Window Will Close?
I have an NSStatusBar application. This is my first in SwiftUI. And I need to know when the window is closed so that I can disable some of menu commands. I can use NSWindowDelegate with AppDelegate as follows. import SwiftUI @main struct SomeApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @StateObject private var menuViewModel = MenuViewModel() var body: some Scene { WindowGroup { ContentView() .environmentObject(menuViewModel) } } } class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var menuViewModel = MenuViewModel() func applicationDidFinishLaunching(_ notification: Notification) { if let window = NSApplication.shared.windows.first { window.setIsVisible(false) window.delegate = self } } func windowWillClose(_ notification: Notification) { menuViewModel.windowClosed = true } } When the window will close, MenuViewModel (ObservableObject) will receive a call, which I want my ContentView to receive. But, so far, it won't. import SwiftUI struct ContentView: View { var body: some View { ZStack { ... ... } .onReceive(statusBarViewModel.$windowClosed) { result in // never called... } } } Can a SwiftUI View receive a call somehow when its window closes? Muchos thankos.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3
1
502
Aug ’24
IOS 18 update causes toolbar contents to not show
I have an app with a TabView containing a view representable containing a SwiftUI View with a toolbar. The representable is providing the toolbar while the .toolbar modifier provides the content. Everything works normally on iOS 17, but on iOS 18 the toolbar contents are not showing. Is this a iOS 18 bug? See the code below for a simplified example. import SwiftUI @main struct TestApp: App { @State var selection: String = "one" var body: some Scene { WindowGroup { TabView(selection: $selection) { Representable() .tabItem { Text("One") } .tag("one") } } } } struct Representable: UIViewControllerRepresentable { let navigationController = UINavigationController() func makeUIViewController(context: Context) -> UINavigationController { navigationController.pushViewController(UIHostingController(rootView: ToolbarView()), animated: false) return navigationController } func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {} } struct ToolbarView: View { var body: some View { NavigationLink("Navigate") { ToolbarView() } .toolbar { ToolbarItem(placement: .principal) { Text("Top") } } } }
11
5
2.2k
Aug ’24
SwiftUI NavigationSplitView - Nested List Not Animating
Hi All! I've encountered a SwiftUI NavigationSplitView bug in my app that I'd appreciate help with, I've spent quite some time trying to work out a solution to this problem. I have a main list, which has either a Location or LocationGroup. When selecting a Location, the detail view is presented. When selecting a LocationGroup, a subsequent list of Locations are presented (from the group). When tapping on any of these Locations, the NavigationStack does not animate (push the view), and when tapping back from it, it jumps to the main selection. The overall goal is to be able to present within the detail: of a NavigationSplitView a NavigationStack, and to be able to push onto that stack from both the main NavigationSplitView's list, and from the detail. I created the following sample code that reproduces the issue: ContentView.swift public enum LocationSplitViewNavigationItem: Identifiable, Hashable { case location(Location) case locationGroup(LocationGroup) public var id: UUID? { switch self { case .location(let location): return location.id case .locationGroup(let locationGroup): return locationGroup.id } } } struct ContentView: View { @State private var columnVisibility = NavigationSplitViewVisibility.doubleColumn @State private var selectedNavigationItem: LocationSplitViewNavigationItem? var body: some View { NavigationSplitView(columnVisibility: $columnVisibility) { LocationListView(selectedItem: $selectedNavigationItem, locationData: LocationSampleData(locations: LocationSampleData.sampleLocations, locationGroups: LocationSampleData.sampleLocationGroups)) } detail: { if let selectedLocation = selectedNavigationItem { switch selectedLocation { case .location(let location): LocationDetailView(selectedLocation: location) case .locationGroup(let locationGroup): LocationListView(selectedItem: $selectedNavigationItem, locationData: LocationSampleData(locations: locationGroup.locations)) } } } .navigationSplitViewStyle(.balanced) } } LocationListView.swift struct LocationListView: View { @Binding public var selectedItem: LocationSplitViewNavigationItem? var locationData: LocationSampleData var body: some View { List(selection: $selectedItem) { if let locations = locationData.locations { ForEach(locations) { location in NavigationLink(value: LocationSplitViewNavigationItem.location(location)) { Text(location.name) .bold() } } } if let locationGroups = locationData.locationGroups { ForEach(locationGroups) { locationGroup in NavigationLink(value: LocationSplitViewNavigationItem.locationGroup(locationGroup)) { Text(locationGroup.name) .bold() .foregroundStyle(.red) } } } } .navigationTitle("Saturday Spots") .navigationBarTitleDisplayMode(.large) } } LocationDetailView.swift struct LocationDetailView: View { var selectedLocation: Location var body: some View { Text(selectedLocation.name) .font(.largeTitle) .bold() .foregroundStyle(LinearGradient( colors: [.teal, .indigo], startPoint: .top, endPoint: .bottom )) .toolbarBackground( Color.orange, for: .navigationBar ) .toolbarBackground(.visible, for: .navigationBar) } } Location.swift import CoreLocation struct LocationSampleData { var locations: [Location]? var locationGroups: [LocationGroup]? static let sampleLocations: [Location]? = Location.sample static let sampleLocationGroups: [LocationGroup]? = [LocationGroup.sample] } public struct Location: Hashable, Identifiable { var name: String var coordinates: CLLocationCoordinate2D var photo: String public var id = UUID() static public let sample: [Location] = [ Location(name: "Best Bagel & Coffee", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf"), Location(name: "Absolute Bagels", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf"), Location(name: "Tompkins Square Bagels", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf"), Location(name: "Zabar's", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf"), ] static public let oneSample = Location(name: "Absolute Bagels", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf") } public struct LocationGroup: Identifiable, Hashable { var name: String var locations: [Location] public var id = UUID() static public let sample: LocationGroup = LocationGroup(name: "Bowling", locations: [ Location(name: "Frames Bowling Lounge", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf"), Location(name: "Bowlero Chelsea Piers", coordinates: CLLocationCoordinate2D(latitude: 123, longitude: 121), photo: "asdf") ]) } extension CLLocationCoordinate2D: Hashable { public static func == (lhs: Self, rhs: Self) -> Bool { return lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude } public func hash(into hasher: inout Hasher) { hasher.combine(latitude) hasher.combine(longitude) } }
2
0
1.2k
Aug ’24
iOS 18 new ControlWidgetButton custom image/icon/symbol not displayed
Hello, I am trying to create a custom control with the new WidgetKit control widget APIs. In my custom control, I want to display a custom image, in fact a custom symbol. The custom symbol is not displayed with latest iOS 18 Seed 7 (22A5346a). Only system symbols are displayed. I don't find any information about it in the WidgetKit Apple Developer Documentation. ControlWidgetButton(action: MyIntent()){ Label(title: { Text("My Custom Control") }, icon: { Image("mycustomsymbol") //NOT DISPLAYED // Image(systemName: "rectangle.portrait.inset.filled") IS DISPLAYED }) } There was no issue with custom symbols in beta 4. Now since beta 5, custom symbols are not displayed. I wonder if this is a bug or this is intended. Can you help me ? I filed a feedback FB14888220 Thank you
5
2
1.1k
Aug ’24
minimumScaleFactor for Text in widgets scales the text.
Hi, In my widgets, I use minimumScaleFactor to ensure that my text is readable. In iOS 18.0 beta 6 and iOS18.0 beta 7, my texts suddenly became very small. It seems that minimumScaleFactor acts like if it was applying the given scale value to the text. minimumScaleFactor(0.1) seems to display the text 90% smaller than the text without calling minimumScaleFactor. minimumScaleFactor(0.5) seems to display the text 50% smaller than the text without calling minimumScaleFactor. Is this a bug, of is there an unexpected change in the API ? Edit : I have created FB14890220, in case this message remains unseen.
8
2
1.2k
Aug ’24