Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

UITabBarController y psoition issue for iOS 18
I am trying to give bottom padding to tabbar i.e ** tabBarFrame.origin.y = view.frame.height - tabBarHeight - 30** but it is not moving up from bottom, it gets sticked to bottom = 0 and the tabbar content moving up taher than tabbar itself.. Code snippet is - `i override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() let tabBarHeight: CGFloat = 70 // Custom height for the capsule tab bar var tabBarFrame = tabBar.frame tabBarFrame.size.height = tabBarHeight tabBarFrame.size.width = view.frame.width - 40 tabBarFrame.origin.y = view.frame.height - tabBarHeight - 30 tabBarFrame.origin.x = 20 tabBar.frame = tabBarFrame tabBar.layer.cornerRadius = tabBarHeight / 2 tabBar.clipsToBounds = true view.bringSubviewToFront(tabBar) }` Can anyone please help to resolve the issue for iOS 18, it is coming in iOS 18 rest previous versions are fine with the code.
0
0
328
Jan ’25
Reading large documents
Can the SwiftUI document architecture Take a file as read-only; never to be written out Take files too large for memory (multi-MB, or even GB) I wouldn't want the system to read a gigabyte size file into memory by default. If the system can use a memory-mapped Data as the representation, that'll be something I can make do. It would be even better if I could tell the system that I'll handle all the reading, all I need from it is a reference to the file's location on disk.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
39
Apr ’25
iOS Architecture Research - Help a student
Hi everyone! I'm thrilled to share that I'm conducting a field research as part of my final university project, focused on iOS architecture. The goal is to dive deeper into the best practices, challenges, and trends in the iOS development world. To make this research truly impactful, I need your help! If you're an iOS developer, I’d love it if you could take a few minutes to answer a short survey. Your insights and experiences will be invaluable for my research, and I greatly appreciate your support! Here is the link: https://docs.google.com/forms/d/e/1FAIpQLSdf9cacfA7my1hnlazyl7uJraa2oTsQ7dJBWvFtZ_4vbYenRA/viewform?usp=send_form Thank you so much in advance for helping me out—feel free to share this post with others who might also be interested. Let’s build something amazing together! 💡✨
0
0
304
Feb ’25
Access DocumentGroup container by external WindowGroup
Hi, I am currently developing a document-based application for macOS and have encountered a challenge related to document container management. Specifically, I need to open a windowGroup that shares the same container as the one used in the DocumentGroup. However, my current approach of using a global shared model container has led to unintended behavior: any new document created is linked to existing ones, and changes made in one document are reflected across all documents. To address this issue, I am looking for a solution that allows each newly created document to be individualized while still sharing the document container with all relevant WindowGroups that require access to the data it holds. I would greatly appreciate any insights or recommendations you might have on how to achieve this. Thank you for your time and assistance. Best regards, Something like: @main struct Todo: App { var body: some Scene { DocumentGroup(editing: Item.self, contentType: .item) { ContentView() } WindowGroup { UndockView() .modelContainer(of documentGroup above) } } }
0
0
75
Apr ’25
drag a modelEntity inside an Immersive space and track position
Goal : Drag a sphere across the room and track it's position Problem: The gesture seems to have no effect on the sphere ModelEntity. I don't know how to properly attach the gesture to the ModelEntity. Any help is great. Thank you import SwiftUI import RealityKit import RealityKitContent import Foundation @main struct testApp: App { @State var immersionStyle:ImmersionStyle = .mixed var body: some Scene { ImmersiveSpace { ContentView() } .immersionStyle(selection: $immersionStyle, in: .mixed, .full, .progressive) } } struct ContentView: View { @State private var lastPosition: SIMD3<Float>? = nil @State var subscription: EventSubscription? @State private var isDragging: Bool = false var sphere: ModelEntity { let mesh = MeshResource.generateSphere(radius: 0.05) let material = SimpleMaterial(color: .blue, isMetallic: false) let entity = ModelEntity(mesh: mesh, materials: [material]) entity.generateCollisionShapes(recursive: true) return entity } var drag: some Gesture { DragGesture() .targetedToEntity(sphere) .onChanged { _ in self.isDragging = true } .onEnded { _ in self.isDragging = false } } var body: some View { Text("Hello, World!") RealityView { content in //1. Anchor Entity let anchor = AnchorEntity(world: SIMD3<Float>(0, 0, -1)) let ball = sphere //1.2 add component to ball ball.components.set(InputTargetComponent()) //2. add anchor to sphere anchor.addChild(ball) content.add(anchor) subscription = content.subscribe(to: SceneEvents.Update.self) { event in let currentPosition = ball.position(relativeTo: nil) if let last = lastPosition, last != currentPosition { print("Sphere moved from \(last) to \(currentPosition)") } lastPosition = currentPosition } } .gesture(drag) } }
0
0
60
Apr ’25
Custom slider png on gui
Im student, hobbyst on developing. i have a problem inserting a custom slidee PNG to control volume of an áudio file in an app. The slidee built in Swift, runs ok. When i try to use a custom png it show in the Gui but when move its button right it disappear beyond the maximum but when i move ir left the minimamente is at middle of the slider scale
Topic: UI Frameworks SubTopic: SwiftUI
0
0
39
Apr ’25
Translate extension bahvior
DESCRIPTION OF PROBLEM We need to add an implementation that will have the same swipe/scroll behavior as the Apple Translator extension, here is the code that we are currently using: import SwiftUI import TranslationUIProvider @main class TranslationProviderExtension: TranslationUIProviderExtension { required init() {} var body: some TranslationUIProviderExtensionScene { TranslationUIProviderSelectedTextScene { context in VStack { TranslationProviderView(context: context) } } } } struct TranslationProviderView: View { @State var context: TranslationUIProviderContext init(context c: TranslationUIProviderContext) { context = c } var body: some View { ScrollableSheetView() } } struct ScrollableSheetView: View { var body: some View { ScrollView { VStack(spacing: 20) { ForEach(0..<50) { index in Text("Item (index)") .padding() .frame(maxWidth: .infinity) .background(Color.blue.opacity(0.1)) .cornerRadius(8) } } .padding() } .padding() } } Using this code, on the first extension run, swipe up will expand the extension (which is OK) but swiping down on the expanded state of the extension works only as a scroll instead of swiping the extension from expanded mode back to compact mode. STEPS TO REPRODUCE Select a text in Safari Tap on Translate in the contextual menu Swipe up on the text ->the extension expands into full mode Swipe down->only scrolls work, I cannot swipe the extension from full mode to compact mode. Expected behavior: when i swipe down on the expanded extension, the extension should get into compact mode, not continuously scroll down.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
66
Apr ’25
How do I maintain a stable scroll position when inserting items above in a ScrollView?
As the title says, I am not sure how to properly build an inverted ScrollView where I can safely insert items above my data ("prepend") without everything jumping around. My current code is essentially this: @State private var scrollPosition = ScrollPosition(idType: Message.ID.self) private func onMessageDidScrollIntoView(_ id: Message.ID) { let indexOfVisibleMessage = /* ... */ if indexOfVisibleMessage < 10 { fetchOlderMessages() // ^ this updates my ViewModel `messages` } } var body: some View { ScrollView { LazyVStack { ForEach(messages) { message in MessageCell(message) } }.scrollTargetLayout() } .defaultScrollAnchor(.bottom) .scrollPosition($scrollPosition) .onChange(of: scrollPosition) { oldValue, newValue in guard let visibleMessageId = scrollPosition.viewID(type: Message.ID.self) else { return } onMessageDidScrollIntoView(visibleMessageId) } } ..so if the user scrolls up to the oldest 10 messages, I start loading more and insert them at the top. The problem with this is that the ScrollView now jumps when new messages are inserted. This is because the ScrollView maintains it's Y position, but the content size changes since we are adding new items "above". I tried to play around with a few suggestions I found on StackOverflow, namely; Inverting the ScrollView (.scaleEffect(y: -1) on the ScrollView and then again on the MessageCell to counter it): This somehow jumped the x position of the ScrollView and completely breaks .contextMenu. Playing around with .onScrollGeometryChange to update scrollPosition.scrollTo(y:) when it's contentSize changes: This just didn't work and stopped the user scroll gesture/interaction. Setting scrollPosition to the Message.ID I want to keep stable before doing an update: This didn't do anything. But nothing actually worked for the reasons described above. How do you actually build these UIs in SwiftUI? I think an inverted ScrollView is quite a common UI, and obviously data has to be loaded lazily.
0
1
101
Apr ’25
Navbar buttons disappear in NavigationSplitView's sidebar when changing apps
We recently migrated our app to use NavigationSplitView on iPad with a sidebar and detail setup, and we got reports that the navigation buttons on the sidebar disappear when returning to our app after using a different app. I reproduced the issue from a new empty project with the following code (issue tested on iOS 17.4 and iOS 18.3, was not able to reproduce on iOS 16.4): import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { NavigationSplitView { Text("sidebar") .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: {}) { Image(systemName: "square.and.arrow.down") } } ToolbarItem(placement: .topBarTrailing) { Button(action: {}) { Image(systemName: "square.and.arrow.up") } } } } detail: { Text("detail") .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: {}) { Image(systemName: "eraser") } } ToolbarItem(placement: .topBarTrailing) { Button(action: {}) { Image(systemName: "pencil") } } } } } } } Please check the following GIF for the simple steps, notice how the navbar buttons in the detail view do not disappear: Here's the console output, it shows that the constraints break internally:
0
0
107
Apr ’25
looking for sample code 3d wireframe (with lines ) & polygons
Looking for sample code 3d wireframe (with lines ) & polygons and should be able to rotate (set camera angles) I tried sample code seems to be complicated & getting a BLANK screen import SwiftUI import SceneKit struct SceneKitTest2: View { var body: some View { VStack{ Text("SceneKitTest2") SceneView(scene: SCNScene(named:"Earth_1_12756.scn"), options: [.autoenablesDefaultLighting,.allowsCameraControl]) .frame(width:UIScreen.main.bounds.width, height: UIScreen.main.bounds.height/2) Spacer(minLength: 0) } } }
0
0
393
Jan ’25
Food Truck Sample animation issue from Table Component
Hi! I'm seeing some weird animation issues building the Food Truck sample application.^1 I'm running from macOS 15.4 and Xcode 16.3. I'm building the Food Truck application for macOS. I'm not focusing on iOS for now. The FoodTruckModel adds new Order values with an animation: // FoodTruckModel.swift withAnimation(.spring(response: 0.4, dampingFraction: 1)) { self.orders.append(orderGenerator.generateOrder(number: orders.count + 1, date: .now, generator: &generator)) } This then animates the OrdersTable when new Order values are added. Here is a small change to OrdersTable: // OrdersTable.swift - @State private var sortOrder = [KeyPathComparator(\Order.status, order: .reverse)] + @State private var sortOrder = [KeyPathComparator(\Order.creationDate, order: .reverse)] Running the app now inserts new Order values at the top. The problem is I seem to be seeing some weird animation issues here. It seems that as soon as the new Order comes in there is some kind of weird glitch where it appears as if part the animation is coming from the side instead of down from the top: What's then more weird is that if I seem to affect the state of the Table in any way then the next Order comes in with perfect animation. Scrolling the Table fixes the animation. Changing the creationData sort order from reverse to forward and back to reverse fixes the animation. Any ideas? Is there something about how the Food Truck product is built that would cause this to happen? Is this an underlying issue in the SwiftUI infra?
0
0
59
Apr ’25
Task cancellation behaviour
Hi everyone, I believe this should be a simple and expected default behavior in a real-world app, but I’m unable to make it work: 1. I have a View (a screen/page in this case) that calls an endpoint using async/await. 2. If the endpoint hasn’t finished, but I navigate forward to a DetailView, I want the endpoint to continue fetching data (i.e., inside the @StateObject ViewModel that the View owns). This way, when I go back, the View will have refreshed with the fetched data once it completes. 3. If the endpoint hasn’t finished and I navigate back to the previous screen, I want it to be canceled, and the @StateObject ViewModel should be deinitialized. I can achieve 1 and 3 using the .task modifier, since it automatically cancels the asynchronous task when the view disappears: view .task { await vm.getData() } I can achieve 1 and 2 using a structured Task in the View (or in the ViewModel, its the same behavior), for example: .onFirstAppearOnly { Task { away vm.getData() } } onFirstAppearOnly is a custom modifier that I have for calling onAppear only once in view lifecycle. Just to clarify, dont think that part is important for the purpose of the example But the question is: How can I achieve all three behaviors? Is this really such an unusual requirement? My minimum deployment target is iOS 15, and I’m using NavigationView + NavigationLink. However, I have also tried using NavigationStack + NavigationPath and still couldn’t get it to work. Any help would be much appreciated. Thank you, folks!
0
0
398
Feb ’25
Replaykit stop screen record failed, recording status is false
I want to record screen ,and than when I call the method stopCaptureWithHandler:(nullable void (^)(NSError *_Nullable error))handler to stop recording and saving file. before call it,I check the value record of RPScreenRecorder sharedRecorder ,the value is false , It's weird! The screen is currently being recorded ! I wonder if the value of [RPScreenRecorder sharedRecorder].record will affect the method stopCaptureWithHandler: -(void)startCaptureScreen { [[RPScreenRecorder sharedRecorder] startCaptureWithHandler:^(CMSampleBufferRef _Nonnull sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error) { //code } completionHandler:^(NSError * _Nullable error) { //code }]; } - (void)stopRecordingHandler { if([[RPScreenRecorder sharedRecorder] isRecording]){ // deal error .sometime isRecording is false }else { [[RPScreenRecorder sharedRecorder] stopCaptureWithHandler:^(NSError * _Nullable error) { }]; } } here are my code.
0
0
80
Apr ’25
VideoToolbox crash in macOS
My Mac app crashes for some users inside VideoToolbox, and I'm not sure what to do with that, and how to fix it. Here are couple of examples that repeating again and again for macOS 15.* Thread 10 Crashed: 0 libsystem_pthread.dylib 0x000000018535a8e0 0x185359000 + 6368 1 VideoToolbox 0x0000000194f3e218 0x194f28000 + 90648 2 VideoToolbox 0x00000001951de384 0x194f28000 + 2843524 3 libxpc.dylib 0x000000018506f2c0 0x185060000 + 62144 4 libxpc.dylib 0x000000018506da14 0x185060000 + 55828 5 libdispatch.dylib 0x00000001851ad674 0x1851a9000 + 18036 6 libdispatch.dylib 0x00000001851c9c88 0x1851a9000 + 134280 7 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672 8 libdispatch.dylib 0x00000001851ca9dc 0x1851a9000 + 137692 9 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672 10 libdispatch.dylib 0x00000001851b5764 0x1851a9000 + 51044 11 libdispatch.dylib 0x00000001851bf4cc 0x1851a9000 + 91340 12 libdispatch.dylib 0x00000001851bf260 0x1851a9000 + 90720 13 libsystem_pthread.dylib 0x00000001853602e4 0x185359000 + 29412 14 libsystem_pthread.dylib 0x000000018535b0fc 0x185359000 + 8444 and Thread 10 Crashed: 0 libsystem_pthread.dylib 0x00000001981fc364 0x1981fb000 + 4964 1 VideoToolbox 0x00000001a85f9964 0x1a81e8000 + 4266340 2 VideoToolbox 0x00000001a847a840 0x1a81e8000 + 2697280 3 libxpc.dylib 0x0000000197f09830 0x197efb000 + 59440 4 libxpc.dylib 0x0000000197f0812c 0x197efb000 + 53548 5 libdispatch.dylib 0x00000001980638a4 0x198048000 + 112804 6 libdispatch.dylib 0x00000001980660e8 0x198048000 + 123112 7 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400 8 libdispatch.dylib 0x0000000198066e4c 0x198048000 + 126540 9 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400 10 libdispatch.dylib 0x0000000198052e60 0x198048000 + 44640 11 libdispatch.dylib 0x000000019805be30 0x198048000 + 81456 12 libdispatch.dylib 0x000000019805bbf0 0x198048000 + 80880 13 libsystem_pthread.dylib 0x0000000198201c0c 0x1981fb000 + 27660 14 libsystem_pthread.dylib 0x00000001981fcb80 0x1981fb000 + 7040 and this one is for macOS 14 Thread 10 Crashed: 0 VideoToolbox 0x000000018f12ac90 0x18f11d000 + 56464 1 VideoToolbox 0x000000018f130a80 0x18f11d000 + 80512 2 VideoToolbox 0x000000018f131090 0x18f11d000 + 82064 3 VideoToolbox 0x000000018f130f94 0x18f11d000 + 81812 4 Remote for Mac 0x00000001048d521c 0x1048d0000 + 21020 5 Foundation 0x000000018174796c 0x181709000 + 256364 6 Foundation 0x000000018174782c 0x181709000 + 256044 7 Foundation 0x00000001817477bc 0x181709000 + 255932 8 Foundation 0x0000000181746b64 0x181709000 + 252772 9 Foundation 0x00000001817468d4 0x181709000 + 252116 10 Foundation 0x00000001817467c4 0x181709000 + 251844 11 libdispatch.dylib 0x00000001803b0470 0x18039d000 + 78960 12 libdispatch.dylib 0x00000001803a13e8 0x18039d000 + 17384 13 libdispatch.dylib 0x00000001803a48ec 0x18039d000 + 30956 14 libdispatch.dylib 0x00000001803a3f08 0x18039d000 + 28424 15 libdispatch.dylib 0x00000001803b2ea8 0x18039d000 + 89768 16 libdispatch.dylib 0x00000001803b36b8 0x18039d000 + 91832 17 libsystem_pthread.dylib 0x000000018054dfd0 0x18054b000 + 12240 18 libsystem_pthread.dylib 0x000000018054cd28 0x18054b000 + 7464
0
0
68
Apr ’25
UICollectionView Dequeue Crash Xcode 16.2
I am facing same issue with major crash while coming out from this function. Basically using collectionView.dequeReusableCell with size calculation. func getSizeOfFavouriteCell(_ collectionView: UICollectionView, at indexPath: IndexPath, item: FindCircleInfoCellItem) -> CGSize { guard let dummyCell = collectionView.dequeueReusableCell( withReuseIdentifier: TAButtonAddCollectionViewCell.reuseIdentifier, for: indexPath) as? TAButtonAddCollectionViewCell else { return CGSize.zero } dummyCell.title = item.title dummyCell.subtitle = item.subtitle dummyCell.icon = item.icon dummyCell.layoutIfNeeded() var targetSize = CGSize.zero if viewModel.favoritesDataSource.isEmpty.not, viewModel.favoritesDataSource.count > FindSheetViewControllerConstants.minimumFavoritesToDisplayInSection { targetSize = CGSize(width: collectionView.frame.size.width / 2, height: collectionView.frame.height) var estimatedSize: CGSize = dummyCell.systemLayoutSizeFitting(targetSize) if estimatedSize.width > targetSize.width { estimatedSize.width = targetSize.width } return CGSize(width: estimatedSize.width, height: targetSize.height) } } We have resolve issue with size calculation with checking nil. Working fine in xcode 15 and 16+. Note: Please help me with reason of crash? Is it because of xCode 16.2 onwards **strict check on UICollectionView **
0
0
135
Apr ’25
Title: Frequent SIGSEGV crashes in QuartzCore's copy_image (iOS 18.4) We're experiencing numerous crashes with the following signature:
Title: Frequent SIGSEGV crashes in QuartzCore's copy_image (iOS 18.4) We're experiencing numerous crashes with the following signature: Exception Codes: fault addr: 0x00000000000000e0 Crashed Thread: 0 Thread 0 0 QuartzCore CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double) + 1972 1 QuartzCore CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double) + 1260 2 QuartzCore CA::Render::prepare_image(CGImage*, CGColorSpace*, unsigned int, double) + 24 3 QuartzCore CA::Layer::prepare_contents(CALayer*, CA::Transaction*) + 220 4 QuartzCore CA::Layer::prepare_commit(CA::Transaction*) + 284 5 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 488 6 QuartzCore CA::Transaction::commit() + 644 7 UIKitCore ___34-[UIApplication _firstCommitBlock]_block_invoke_2 + 36 8 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 9 CoreFoundation ___CFRunLoopDoBlocks + 352 10 CoreFoundation ___CFRunLoopRun + 868 11 CoreFoundation _CFRunLoopRunSpecific + 572 12 GraphicsServices _GSEventRunModal + 168 13 UIKitCore -[UIApplication _run] + 816 14 UIKitCore _UIApplicationMain + 336 15 kugou _main + 132 16 dyld __dyld_process_info_create + 33284 Observations: 1.Crashes consistently occur in Core Animation's image processing pipeline 2.100% of occurrences are on iOS 18.4 devices 3.Crash signature suggests memory access violation during image/copy operations 4.Not tied to any specific device model Questions for Apple: 1.Is this crash pattern recognized as a known issue in iOS 18.4? 2.Are there specific conditions that could trigger SEGV_ACCERR in CA::Render::copy_image? 3.Could this be related to color space handling or image format requirements changes? 4.Any recommended workarounds while waiting for a system update?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
119
Apr ’25
SwiftUI image has isAccessibilityElement == false
My SwiftUI app uses an Image with a tap gesture: Image(systemName: "xmark.circle.fill") .accessibilityIdentifier(kTextFieldClearButton) .foregroundColor(.secondary) .padding(.trailing, 6) .onTapGesture { dataSource.textFieldText = "" } In a UI test, I want to tap this image to execute its action: let clearButton = app.images[kTextFieldClearButton] clearButton.tap() However the action is not executed. I then set a breakpoint at clearButton.tap(), to execute lldb commands. Here are the results: (lldb) p clearButton.isHittable t = 439.54s Find the "TextFieldClearButton" Imag (Bool) true e It is a little strange that "Image" has been interrupted by (Bool) true, but the image is hittable. p clearButton.isAccessibilityElement gives (lldb) p clearButton.isAccessibilityElement (Bool) false I don't understand why this Image is no accessibility element. I thought, SwiftUI Views are by default accessible. What can I do to make it accessible so that clearButton.tap() works as expected?
0
0
511
Dec ’24
Longtime UIStackView Bug
There has been a long lasting UIStackView bug dating back to 2016 that still exists in the latest Xcode 16.3 and SDKs, where calling setHidden:true multiple times (lets say twice) on a subview of that stack view requires calling setHidden:false twice before the subview shows up again. This was originally documented via Radar #25087688. Hopefully a Frameworks Engineer here on the forums can raise it to the attention of the appropriate engineers. It would be really nice if this eventually gets fixed, because it's one of those odd issues where you end up wasting a lot of time trying to debug because everything looks correct.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
77
Apr ’25