Hi,
I came across the following API:
@MainActor
func placeCursor(at position: UITextPosition!, animated: Bool)
From the signature, it seems intended to move the insertion point (caret) to a given UITextPosition, with an option for animation.
However, UITextView and UITextField don’t seem to expose this method as a public member — calling it gives the error:
Value of type 'UITextView' has no member 'placeCursor'
My questions are:
Is placeCursor(at:animated:) a public, supported API that we can safely use in apps?
If not, what is the Apple-recommended way to programmatically move the cursor without animation?
Right now, I only know of updating selectedTextRange, which works but doesn’t involve this placeCursor method. I want to confirm if placeCursor is meant for developer use or is an internal/private API.
Thanks!
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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
When I display 2/3 of the poster on tvos, after setting it according to the code, some semi-transparent background can be seen in the upper left and right corners of the image when it is in focus. How can I eliminate it?
struct HighPosterView: View {
let media: MediaDetail
@State private var isShowingDetails = false
@Environment(\.isFocused) private var isFocused: Bool
var body: some View {
Button {
isShowingDetails.toggle()
} label: {
HighShelfImageView(imageURL: media.posterURL)
.contentShape(RoundedRectangle(cornerRadius: 24, style: .continuous))
.hoverEffect(.highlight)
Text(media.displayTitle)
.lineLimit(1)
.font(.subheadline)
.frame(maxWidth: 300)
}
.buttonStyle(.borderless)
.animation(.smooth)
}
}
struct HighShelfImageView: View {
let imageURL: URL?
var body: some View {
KFImage.url(imageURL)
.targetCache(ImageCacheManager.shelfCache)
.setProcessor(ImageCacheManager.mediaListShelfProcessor)
.placeholder {
Color.primary.opacity(0.1)
.cornerRadius(Constants.cornerRadius)
}
.cancelOnDisappear(true)
.cacheMemoryOnly(false)
.fade(duration: 0.1)
.cacheOriginalImage(true)
.resizable()
.aspectRatio(2/3, contentMode: .fill)
.clipShape(RoundedRectangle(cornerRadius: Constants.cornerRadius))
}
}
I need to keep the image and text distributed vertically, keep customize corner, with the text pushed aside when the image is in focus.
If the NavigationSplitView on iPadOS 26 is combined with a .inspector column, the sidebarToggle is always hidden, when the sidebar is collapsed. If you remove the .inspector modifier, the sidebarToggle stays visible throughout the collapsed or expanded state.
Has maybe someone a workaround for this issue?
The problem does not exist in iOS 18.
The bug is reported as FB20061260
When UIStatusBarHidden is set to YES, the navigation bar is displayed in the wrong vertical position immediately after app launch. The layout only corrects itself after the device orientation changes (e.g., rotation).
Steps to Reproduce:
Create a new app with a navigation controller.
Set UIStatusBarHidden = YES in Info.plist.
Launch the app.
Expected Result:
The navigation bar should appear in the correct position immediately after launch.
Actual Result:
The navigation bar is misaligned on first launch, and only moves to the correct position after rotating the device.
The "Cancel" button for VNDocumentCameraViewController is not displayed on iPadOS 26. This issue appears to be specific to iPad, as the button appears correctly on iPhone.
I've been trying to update my apps for iOS 26, and all summer I kept hitting this issue with the navigation bar title. I was hoping Apple would eventually fix it, but it still seems to be broken in beta 9, so now I'm wondering if I'm doing something wrong.
Here's a minimal working example:
struct ContentView: View {
@State private var path = NavigationPath()
var body: some View {
NavigationStack(path: $path) {
List {
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
.navigationTitle("Title")
.toolbarBackground(Color(red: 0.5, green: 0.5, blue: 0.5), for: .navigationBar)
.toolbarBackgroundVisibility(.visible, for: .navigationBar)
}
}
}
Expected result: The title should be rendered on a gray background.
Actual result: The title is invisible because it is rendered below the gray background.
If I modify the gray color with .opacity(0.5), then it becomes clear that the title is indeed present, but it's behind the background.
This example works correctly in iOS 18.
Is this an iOS 26 bug or is this a forbidden design now because everything has to be translucent?
Topic:
UI Frameworks
SubTopic:
SwiftUI
We tested this on 2 devices:
on first device the colors show properly
on the other device the colors are either light or dark gray
Seems as if the colors weren't picked up properly by the app.
Tested on iOS 26 23A5336a.
There was no issue before
Topic:
UI Frameworks
SubTopic:
SwiftUI
Since iOS 26, when using toolbar items with .keyboard placement, the view inside the hierarchy which is pushed, does not directly stick to the toolbar anymore when a text field is focused, creating a gap, or moving the view below the toolbar. Focusing another field pushes the layout below the toolbar.
Minimal example to reproduce the issue.
import SwiftUI
import Foundation
@main
struct testfocusApp: App {
@State var showSheet = false
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
enum Field: Hashable {
case body
case title
}
@State var titleText = ""
@State var bodyText = ""
@FocusState private var focusedField: Field?
var body: some View {
NavigationView {
VStack(spacing: 0) {
ScrollView {
VStack(spacing: 16) {
TextField("", text: $titleText)
.onSubmit {
focusedField = .body
}
.background(Color.red)
.focused($focusedField, equals: .title)
VStack(spacing: 0) {
VStack {
Text(bodyText)
.padding(.vertical, 9)
.padding(.horizontal, 5)
.hidden()
TextEditor(
text: $bodyText
)
.focused($focusedField, equals: .body)
}
}
}
.padding(20)
}
Spacer()
VStack(spacing: 16) {
Text("message")
Button {
} label: {
Text("Save")
.frame(maxWidth: .infinity)
}
}
.border(Color.red)
.background(Color.green)
}
.background(Color.yellow)
.border(Color.purple)
.toolbar {
ToolbarItem(placement: .keyboard) {
Button("Done") {
}
.border(Color.purple)
}
}
}
}
}
I have a PDF which contains geocoordinates. I'm extracting out that image with the following code (this is for an iOS application):
guard let cgDocument = CGPDFDocument(overlay.pdfUrl as CFURL) else { return }
guard let cgPage = cgDocument.page(at: 1) else { return }
var boundingRect = self.rect(for: overlay.boundingMapRect)
let pdfPageRect = cgPage.getBoxRect(.mediaBox)
let renderer = UIGraphicsImageRenderer(size: pdfPageRect.size)
var img = renderer.image { ctx in
UIColor.white.set()
ctx.fill(pdfPageRect)
ctx.cgContext.translateBy(x: 0.0, y: pdfPageRect.size.height)
ctx.cgContext.scaleBy(x: 1.0, y: -1.0)
ctx.cgContext.drawPDFPage(cgPage)
}
Once I have that image, I then need to adjust it to fit the specific coordinate corners. For that, I'm doing the following using a perspectiveTransform:
let ciImg = CIImage(image: img)!
let perspectiveTransformFilter = CIFilter.perspectiveTransform()
perspectiveTransformFilter.inputImage = ciImg
perspectiveTransformFilter.topRight = cartesianForPoint(point: ur, extent: boundingRect)
perspectiveTransformFilter.topLeft = cartesianForPoint(point: ul, extent: boundingRect)
perspectiveTransformFilter.bottomRight = cartesianForPoint(point: lr, extent: boundingRect)
perspectiveTransformFilter.bottomLeft = cartesianForPoint(point: ll, extent: boundingRect)
let txImg = perspectiveTransformFilter.outputImage!
img = UIImage(ciImage: txImg)
The original image is 792 x 612 (a landscape PDF) but the boundingRect covering the coordinates is 25625 x 20030. Obviously when I try to draw the image into that bounding box the app runs out of memory (25625 x 20030 x 4 is around 2GB of memory).
What I'm struggling with is - how do I correctly scale this image to fit into the bounding box even though the bounding box is, oh, 10x the resolution of the actual device? There's some key CoreGraphics thing I'm sure I'm missing here.
One screen in my app uses a navigation bar with some buttons added to the titleView and some buttons added as a customView of a single rightBarButtonItem.
In iOS 26 (beta 9), if I switch to the home screen and back again, the titleView and rightBarButtonItem disappear and an overflow button (three dots) appears instead. Nothing happens when I click the overflow button. Here's a screen capture:
https://youtu.be/tthRnMz98kA
This also happens when I switch to another app, when I rotate the device or when I resize the app window. In all cases, there is enough room to show all the buttons, but they still disappear.
I overrode the viewWillTransition function in my view controller and logged when that runs. I can see that if I switch to the home screen and back again before that runs (within one or two seconds), there's no problem. But once that runs, the navigation bar items disappear and the overflow button appears.
I have not done anything to set up the overflow button and don't have any need to use it. The documentation about it isn't very detailed, but it seems like it shouldn't be used unless I add it. This wasn't a problem in iOS 18 or earlier iOS versions.
Does anyone know how to stop this?
BTW, I'm using Swift, but not SwiftUI.
Topic:
UI Frameworks
SubTopic:
UIKit
Environment
iOS 26.0 (device), Xcode 26 beta 7
SwiftUI TabView using the new Tab("…", value:) API
iPhone only (aware that minimize is iPhone-only)
Issue
.tabBarMinimizeBehavior(.onScrollDown) only works reliably in my Settings tab.
In my other tabs (Dashboard / Games / Help), the tab bar does not minimize when scrolling, even though the content is scrollable.
The main difference: those tabs are wrapped in a NavigationStack(path:) with a bound NavigationPath. Settings has no path binding.
Repro (minimal)
import SwiftUI
enum TabSel: Hashable { case dashboard, games, settings }
struct Root: View {
@State private var selection: TabSel = .dashboard
// Per-tab paths
@State private var dashPath = NavigationPath()
@State private var gamesPath = NavigationPath()
var body: some View {
if #available(iOS 26, *) {
TabView(selection: $selection) {
// ❌ Does NOT minimize when scrolling
SwiftUI.Tab("Dashboard", systemImage: "square.grid.2x2.fill", value: .dashboard) {
NavigationStack(path: $dashPath) {
ScrollView {
// ...
}
}
}
// ❌ Same here
SwiftUI.Tab("Games", systemImage: "sportscourt.fill", value: .games) {
NavigationStack(path: $gamesPath) {
ScrollView {
// ...
}
}
}
// ✅ Minimizes as expected on scroll
SwiftUI.Tab("Settings", systemImage: "gear", value: .settings) {
// Note: also inside a NavigationStack, but no `path` binding
NavigationStack {
ScrollView {
// ...
}
}
}
}
.tabBarMinimizeBehavior(.onScrollDown)
}
}
}
What I tried
Removing nested stacks in child views → no change
Ensured no .tabViewStyle(.page) / PageTabViewStyle() anywhere
No toolbar(.hidden, for: .tabBar) on the tab roots
Confirmed the content is scrollable and tested on device
Expected
All tabs should minimize the tab bar on downward scroll.
Actual
Only the Settings tab (no path binding) minimizes; tabs with NavigationStack(path:) do not.
Questions
Is this a known issue with NavigationStack(path:) and .tabBarMinimizeBehavior in iOS 26 betas?
Any recommended workaround that keeps a bound NavigationPath per tab?
I'm working on updating our iOS app for the latest Xcode version and noticed the new UIDesignRequiresCompatibility key requirement in Info.plist for apps targeting older iOS designs (without liquid glass). Is there an official timeline for when this compatibility key will be deprecated/removed so that we can plan our liquid glass design changes?
Here is a simple view to demonstrate the issue
struct ContentView: View {
@State private var isPresented = false
var body: some View {
VStack {
Button("Test") { isPresented = true }
}
.alert("Test", isPresented: $isPresented, actions: {
Button("Delete All", role: .destructive) {}
}, message: {
Text("Are You Sure?")
})
.padding()
}
}```
Which results in

The destructive button is almost unreadable. WCAG score is 1.4, far below the minimum recommended 4.5.
I found [this post](https://stackoverflow.com/q/66448869) on SO going back to Big Sur, but not on this forum.
Any known workarounds (except for building my own dialogs, which I am trying to avoid)?
Using confirmationDialog instead of alert does not make a difference.
I’m trying to keep a specific row visually stable while the data backing a ScrollView changes.
Goal
1. Before updating model.items, capture the top row’s offset relative to the scroll view.
2. Mutate the observable state so SwiftUI recomputes layout — but don’t draw yet.
3. Read the new layout, compute the delta, and adjust the scroll position so the previously visible row stays put.
4. Only then draw the new frame.
Reduced example
@Observable
final class SomeModel {
var items: [SomeItem] = [/* ... */]
}
struct MyBox: View {
@Environment(SomeModel.self) private var model
var body: some View {
ScrollView {
VStack {
ForEach(model.items, id: \.id) { item in
Color.red.frame(height: randomStableHeight(for: item.id))
}
}
}
}
}
// Elsewhere:
let oldRow = recordOldRow() // capture the row to stabilize
model.items = generateNewItems() // mutate model (invalidates layout)
let newPos = capturePreviousRowNewPosition(oldRow) // read new layout?
restoreScrollPosition() // adjust so oldRow stays visually fixed
// draw now
Is that pipeline achievable in SwiftUI? If not, what’s the supported way to keep a row visually stable while the list updates?
In iOS 26, should we have bootloader that runs the repo on startup - or should we have that inside tasks in root view?
we have repos that runs as a «closed» functions, we dont throw but updates swiftdata and we use @query in the views. So what is best?
and for the repo we should have a repo that runs the upserts manage relations eg? Should that run on a modelactor?
I have been banging my head against this problem for a bit now.
I am trying to build a bidirectional, infinitely scrolling list that implements these core requirements:
Loads data up/down on the fly as the user scrolls
Preserves scroll velocity as the list is updated
Restores the scroll to the exact visual location after data has changed
Ensures no flicker when restoring scroll position - the user cannot know the list has updated and should continue scrolling as normal
Because LazyVStack does not play well with animations, I am opting to go with VStack and am implementing my own sliding window for data. This means that data can be removed as well as added, and a simple application of a height delta is not enough when restoring position.
So far I have tried many things:
Relying on ScrollPosition - simply does not work by itself as described (swift UI trying to keep the position stable with ID's)
Relying on ScrollPosition.scrollTo - only kind of works with ID, no way to restore position with pixel perfect accuracy
Intercepting the UIKit scrollView instance, using it to record and access the top row's position, mutating data and then queuing a scroll restoration using CATransaction.setCompletionBlock - this is the closest I've come, and it satisfies the top 3 requirements but sometimes I get a flicker on slightly heavier lists
What I would really like, is a way of using ScrollView and granularly hooking into the lifecycle of the view after layout, and just before draw. At this point I would update the relevant scroll positions, and allow draw to continue. Is this possible? My knowledge is very limited at this point, but I believe I may be able to achieve something of the sort by swizzling layerWillDraw? Does this make sense, and is it prudent?
In general, I'm very interesting in hearing what people have to say about the above, as well as this problem in general.
i am try to build an app that show beautiful result represent the user activity.
but i found that if i write metal code in the View of some DeviceActivityReportScene, the metal code wasn't working.
(the same metal code works in other taget)
i can switch to canvas, but the perform is bad compare with metal.
can use metal? or it is just not working?
Hi everyone,
I’m running into a strange animation glitch when using a Menu inside a glassEffect container.
Here’s a minimal example:
import SwiftUI
struct ContentView: View {
@Namespace private var namespace
var body: some View {
ZStack {
Image(.background)
.resizable()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.ignoresSafeArea()
GlassEffectContainer {
HStack {
Button("b1") {}
Button("b2") {}
Button("b3") {}
Button("b4") {}
Button("b5") {}
Menu {
Button("t1") { }
Button("t2") { }
Button("t3") { }
Button("t4") { }
Button("t5") { }
} label: {
Text("Menu")
}
}
}
.padding(.horizontal)
.frame(height: 50)
.glassEffect()
}
}
}
What happens:
The bar looks fine initially:
When you open the Menu, the entire bar morphs into the menu:
When dismissing, the bar briefly animates into a solid rectangle before reapplying the glass effect:
Questions:
Is there a way to prevent that brief rectangle animation when dismissing the menu?
If not, is it possible to avoid the morphing altogether and have the menu simply overlay on top of the bar instead of replacing it?
Any ideas or workarounds would be greatly appreciated!
Hi everyone!
I've encountered an issue when using Sheet + ScrollView on Mac Catalyst: the buttons in the toolbar appear with an abnormal gray color.
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
}
.sheet(isPresented: .constant(true)) {
Sheet()
}
}
}
struct Sheet: View {
var body: some View {
NavigationStack {
ScrollView { // <-- no issue if use List
}
.toolbar {
Button(action: {}) { // <-- 👀 weird gray color
Image(systemName: "checkmark")
}
}
}
}
}
Steps to Reproduce:
On macOS 26.0 beta 9, use Xcode 26.0 beta 7 to create an iOS project and enable Mac Catalyst.
Paste the code above.
Select the Mac Catalyst scheme and run the project.
The buttons in the toolbar show a strange gray appearance.
If you change the ScrollView to a List in the code, the issue does not occur.
FB20120285
I just made a small test app that uses SwiftData with CloudKit capability. I created a simple Book model as seen below. It looks like enums and structs when used with CloudKit capability all trigger this error:
'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
I fixed the error by using genreRaw String and using a computed property to use it in the app, but it popped back up after adding the ReadingProgress struct
Should I ignore the error and assume Apple still supports enums and codable structs when using SwiftData with CloudKit?
import SwiftData
@Model
class Book {
var title: String = ""
var author: String = ""
var genreRaw: String = Genre.fantasy.rawValue
var review: String = ""
var rating: Int = 3
var progress: ReadingProgress?
var genre: Genre {
get { Genre(rawValue: genreRaw) ?? Genre.fantasy }
set { genreRaw = newValue.rawValue }
}
init(title: String, author: String, genre: Genre, review: String, rating: Int, progress: ReadingProgress? = nil) {
self.title = title
self.author = author
self.genre = genre
self.review = review
self.rating = rating
self.progress = progress
}
}
struct ReadingProgress: Codable {
var currentPage: Int
var totalPages: Int
var isFinished: Bool
var percentComplete: Double {
guard totalPages > 0 else { return 0 }
return Double(currentPage) / Double(totalPages) * 100
}
}
enum Genre: String, Codable, CaseIterable {
case fantasy
case scienceFiction
case mystery
case romance
var displayName: String {
switch self {
case .fantasy:
return "Fantasy"
case .scienceFiction:
return "Science Fiction"
case .mystery:
return "Mystery"
case .romance:
return "Romance"
}
}
}