(I made a mistake and saved too soon. Nothing to see here. Sorry!)
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi all,
Is there a standard, good intuition about RealityKit battery drain vs how the Xcode profiler tends to display things?
I have a realitykit ARview that i have permanently in my view hierarchy and the profiler is saying constantly 40% CPU spin, ~160mb increase of memory usage compared to when not using this view, and battery increased from Low to middle of the yellow bar for "high".
Yet the actual battery drain attributed to my app is basically an order of magnitude lower than the battery drain of something like Tiktok for the same amount of foreground time (15% vs 2%)
So I'm a little confused whether or not to trust the Xcode battery profiler when working with RealityKit and ARViews (unless Tiktok is in very high usage all the time!). Is this a largely ignorable signal, and more generally, how useful is this profiler? Doesn't seem immediately intuitive to me at first use.
Thanks!
On WWDC25 session "Meet Liquid Glass", two Liquid Glass variants are mentioned: "regular" and "clear". "Regular" seems to be the default setting for UIGlassEffect, but I was not able to find an option for clear.
Is there a native element that uses clear? Is it coming to later betas for iOS 26?
Fellow iOS developers, can you tell me how to make UIDatePicker usable on iOS 26?
Hi,
I'm seeing an issue in iOS 26 beta related to UINavigationBar rendering in landscape.
When a background color is set for the navigation bar and the device is rotated to landscape, an unexpected gap appears above the navigation bar.
This also happens in the official sample project provided in Apple’s documentation:
https://developer.apple.com/documentation/uikit/customizing-your-app-s-navigation-bar
Is this a bug in the beta, or is there a workaround to avoid this behavior?
Thanks in advance!
I have a custom document-based iOS app that also runs on macOS. After implementing -activityItemsConfiguration to enable sharing from the context menu, I found that the app crashes on macOS when selecting Share… from the context menu and then selecting Save (i.e. Save to Files under iOS). This problem does not occur on iOS, which behaves correctly.
- (id<UIActivityItemsConfigurationReading>)activityItemsConfiguration {
NSItemProvider * provider = [[NSItemProvider alloc] initWithContentsOfURL:self.document.presentedItemURL];
UIActivityItemsConfiguration * configuration = [UIActivityItemsConfiguration activityItemsConfigurationWithItemProviders:@[ provider ]];
// XXX crashes with com.apple.share.System.SaveToFiles
return configuration;
}
Additionally, I found that to even reach this crash, the workaround implemented in the NSItemProvider (FBxxx) category of the sample project is needed. Without this, the app will crash much earlier, due to SHKItemIsPDF() erroneously invoking -pathExtension on an NSItemProvider. This appears to be a second bug in Apple’s private ShareKit framework.
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
@implementation NSItemProvider (FBxxx)
// XXX SHKItemIsPDF() invokes -pathExtension on an NSItemProvider (when running under macOS, anyway) -> crash
- (NSString *)pathExtension {
return self.registeredContentTypes.firstObject.preferredFilenameExtension;
}
@end
Again, this all works fine on iOS (17.5) but crashes when the exact same app build is running on macOS (14.5).
I believe these bugs are Apple's. Any idea how to avoid the crash? Is there a way to disable the "Save to Files" option in the sharing popup?
I filed FB13819800 with a sample project that demonstrates the crash on macOS. I was going to file a TSI to get this resolved, but I see that DTS is not responding to tech support incidents until after WWDC.
Topic:
UI Frameworks
SubTopic:
UIKit
This may seem really basic, but I'm not using the screen designer, I'm doing this old school (programmatically).
I think I'm using Swift 5 (not actually sure). This image may help.
So I created my own UIImageView class called GenericImage
class GenericImage: UIImageView, @unchecked Sendable { ... }
I create the GenericImage class and add it to the View Controller. Then I load the image and set some positioning within my GenericImage class
let imageView = GenericImage(frame: CGRect.zero)
self.view.addSubview(imageView)
imageView.processResponse(componentDictionary )
In the GenericImage class I load the image and set some constraints.
self.imageFromURL(urlString: imageUrl)
self.translatesAutoresizingMaskIntoConstraints = false
self.contentMode = .scaleAspectFit
self.widthAnchor.constraint(equalToConstant: 100.0).isActive = true
self.heightAnchor.constraint(equalToConstant: 100.0).isActive = true
self.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
self.topAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
The image is displayed at the top left of the screen.
I'm guessing that the code I have written should center the image on the screen. However, while I would like to know how to center the image, I also want to be able to position it at a specific place on the screen, using points (or pixels).
Any suggestions?
When composing tabs like this and selecting them in the sidebar, only the group's view controller is ever displayed, even when selecting the individual first and second tabs. Their view controllers are just ignored. Am I immensely stupid here or is this a bug in iPadOS 26 beta 3?
// First tab
let firstTab = UITab(
title: "First",
image: UIImage(systemName: "heart"),
identifier: "hello"
) { _ in
UINavigationController(rootViewController: ViewController())
}
// Second tab
let secondTab = UITab(
title: "Second",
image: UIImage(systemName: "heart"),
identifier: "hello2"
) { _ in
UIViewController()
}
// Tab group
let tabGroup = UITabGroup(
title: "Stuff",
image: nil,
identifier: "stuff",
children: [firstTab, secondTab]
) { _ in
ViewController()
}
let tbc = UITabBarController(tabs: [tabGroup])
tbc.mode = .tabSidebar
Topic:
UI Frameworks
SubTopic:
UIKit
I am currently having an issue in where whenever I place a UITextView with text that's long, it simply pushes past the width of the container it is in, and when I do try and set a width, it does auto wrap and ignores that. I do not come from UIKit and come from SwiftUI, through a mix of ChatGPT and Stack overflow, I have come up with this solution, however, are there any better/simpler ones, I dont want to have to use expensive GeoReaders just to get a width.
struct AutoDetectedPhoneNumberView: UIViewRepresentable {
let text: String
var width: CGFloat
func makeUIView(context: Context) -> UITextView {
let textView = UITextView()
textView.dataDetectorTypes = [.phoneNumber]
textView.isEditable = false
textView.isScrollEnabled = false
textView.backgroundColor = .clear
textView.font = UIFont.systemFont(ofSize: 16)
textView.textContainer.lineBreakMode = .byWordWrapping
textView.translatesAutoresizingMaskIntoConstraints = false
print(width)
NSLayoutConstraint.activate([
textView.widthAnchor.constraint(equalToConstant: width)
])
return textView
}
func updateUIView(_ uiView: UITextView, context: Context) {
uiView.text = text
}
}
GeometryReader { geo in
AutoDetectedPhoneNumberView(text: phone, width: geo.size.width)
}
iOS 26 Beta 3 finally introduced an API for the clear variant of Liquid Glass. But is there any way to switch system controls like the NavigationController back button or UIBarButtonItems to clear? They do not accept an effect like UIEffectView, and they do not have a configuration property like UIButton.
I have attached two images of two screens below. In one screen, bar button are enclosed within separate, distinct, rounded-rectangle 'liquid glass' capsules. In other screen, bar buttons are enclosed within separate, distinct, rounded-rectangle "liquid glass" capsules. They are not visually merged into one larger capsule.
Both are having same code. But why it is not same ?
Hi team, while i am using below code, i am getting two searchBar at top & bottom. Kindly refer below code & attached image
Code:
override func viewDidLoad() {
super.viewDidLoad()
title = "Test Data"
setupSearchData()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.setupSearchData()
}
}
func setupSearchData() {
navigationController?.navigationBar.prefersLargeTitles = false
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
}
It is working fine for other iOS versions. In my real useCase, i will refresh screen after API completed, then this issue occurred in my app.
My view structure in UIKit is like this: UITabBarController (with UITabBar) -> UINavigationController -> UIToolbar (by setting self.navigationController.toolbarHidden = NO). The toolbar is shown in red in the picture. I'm using it like so:
self.navigationController.toolbarHidden = NO;
self.toolbarItems = @[element1, element2];
This toolbar does work fine up to iOS 18.5 but it does not show up when compiling using iOS 26 Beta 3. Is this a bug?
I don't see any deprecation in the documentation about it. Am I doing something wrong?
In WWDC25 video 284: Build a UIKit app with the new design, there is mention of a cornerConfiguration property on UIVisualEffectView. But this properly isn't documented and Xcode 26 isn't aware of any such property.
I'm trying to replicate the results of that video in the section titled Custom Elements starting at the 19:15 point. There is a lot of missing details and typos in the code associated with that video.
My attempts with UIGlassEffect and UIViewEffectView do not result in any capsule shapes. I just get rectangles with no rounded corners at all.
As an experiment, I am trying to recreate the capsule with the layers/location buttons in the iOS 26 version of the Maps app.
I put the following code in a view controller's viewDidLoad method
let imgCfgLayer = UIImage.SymbolConfiguration(hierarchicalColor: .systemGray)
let imgLayer = UIImage(systemName: "square.2.layers.3d.fill", withConfiguration: imgCfgLayer)
var cfgLayer = UIButton.Configuration.plain()
cfgLayer.image = imgLayer
let btnLayer = UIButton(configuration: cfgLayer, primaryAction: UIAction(handler: { _ in
print("layer")
}))
var cfgLoc = UIButton.Configuration.plain()
let imgLoc = UIImage(systemName: "location")
cfgLoc.image = imgLoc
let btnLoc = UIButton(configuration: cfgLoc, primaryAction: UIAction(handler: { _ in
print("location")
}))
let bgEffect = UIGlassEffect()
bgEffect.isInteractive = true
let bg = UIVisualEffectView(effect: bgEffect)
bg.contentView.addSubview(btnLayer)
bg.contentView.addSubview(btnLoc)
view.addSubview(bg)
btnLayer.translatesAutoresizingMaskIntoConstraints = false
btnLoc.translatesAutoresizingMaskIntoConstraints = false
bg.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
btnLayer.leadingAnchor.constraint(equalTo: bg.contentView.leadingAnchor),
btnLayer.trailingAnchor.constraint(equalTo: bg.contentView.trailingAnchor),
btnLayer.topAnchor.constraint(equalTo: bg.contentView.topAnchor),
btnLoc.centerXAnchor.constraint(equalTo: bg.contentView.centerXAnchor),
btnLoc.topAnchor.constraint(equalTo: btnLayer.bottomAnchor, constant: 15),
btnLoc.bottomAnchor.constraint(equalTo: bg.contentView.bottomAnchor),
bg.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
bg.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 40),
])
The result is pretty close other than the complete lack of capsule shape.
What changes would be needed to get the capsule shape? Is this even the proper approach?
Sample Project
In iPadOS 26 beta4, when a UISplitViewController transitions to compact layout and proposes the secondary view controller, a crash occurs:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar, <UINavigationBar: 0x1018205b0; frame = (0 0; 320 54); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x600000d37cc0>; layer = <CALayer: 0x600000d13390>> delegate=0x102826600, when the top item belongs to a different navigation bar. topItem = <UINavigationItem: 0x101af3b20> title='Detail' style=navigator rightBarButtonItems=0x600000011e10, navigation bar = <UINavigationBar: 0x101817680; frame = (0 0; 320 54); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x600000d12310>; layer = <CALayer: 0x600000d116b0>> delegate=0x102826000, possibly from a client attempt to nest wrapped navigation controllers.'
When we show the primary view, there is no crash. Similarly, there is no crash on beta-3.
To reproduce the crash in the demo project:
Launch the project on an iPad.
"Try the Demo"
Tap "List-Detail Pattern"
To trigger the crash, select any of the list items and switch the app to a compact layout. The crash occurs because the app will attempt to propose the secondary view controller.
To avoid the crasah, refrain from selecting an item in the list and switch to the compact layout. The app will not crash because it will attempt to propose the primary view controller.
Topic:
UI Frameworks
SubTopic:
UIKit
In beta 2 using layer.cornerRadius on a UIEffectView with the UIGlassEffect allowed you to change the corner radius of the view. In beta 3, this no longer works. WWDC videos indicate the right way to do this is to set the cornerConfiguration on the UIEffectView, but that API doesn't seem to be available yet. At this time it doesn't seem like theres a way to have a glass view that isn't pill shaped.
I'm working on an old Objective-C project and I'm trying to adapt iOS 26 and liquid glass to current UI. I'm facing an issue that the three dot buttons won't automatically move inside navigation item bar/group after resizing window, instead it displays on top of the navigation left item.
App runs entirely on iPad.
What I tried:
Added Application Scene Manifest to Info.plist
Added SceneDelegate and initialized window by windowScene but most old code are still inside AppDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
let appDelegate = UIApplication.shared.delegate as! TDRAppDelegate
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let scene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: scene)
window?.isHidden = false
appDelegate.window = window
appDelegate.initWithWindow()
}
}
- (void)initWithWindow {
...
[self initViewControllers];
NSArray *tabArray = [self getTabArray];
self.mainTabVC = [[MainTabBarViewController alloc] init:tabArray];
self.window.rootViewController = self.mainTabVC;
[self.window setHidden:false];
...
}
Added these 2 delegate functions to AppDelegate
What I'm trying to achieve:
When using UIPageViewController inside a UITabBarController on iOS 26 with Liquid Glass adoption, visiting the PageViewController tab applies a blur effect to the navigation bar and tab bar even though the current child view controller of the pageView is not scrollable and does not reach behind these bars.
Questions:
Is this the expected behavior that the pageview's internal scroll view causes the bars to blur regardless of the page view's child content’s scrollability?
If so, is there an official way to make the blur effect appear only when the pageview's current child view controller actually scrolls behind the navigation bar or tab bar, and not in static cases?
Tried the same in SwiftUI using TabView and TabView with page style. Facing the same issue there as well.
Sample screenshots for reference,
Sample SwiftUI code,
struct TabContentView: View {
var body: some View {
TabView {
// First Tab: Paging View
PagingView()
.tabItem {
Label("Pages", systemImage: "square.fill.on.square.fill")
}
// Second Tab: Normal View
NavigationStack {
ListView()
}
.tabItem {
Label("Second", systemImage: "star.fill")
}
// Third Tab: Normal View
PageView(color: .blue, text: "Page 3")
.tabItem {
Label("Third", systemImage: "gearshape.fill")
}
}
.ignoresSafeArea()
}
}
struct PagingView: View {
var body: some View {
TabView {
PageView(color: .red, text: "Page 1")
PageView(color: .green, text: "Page 2")
PageView(color: .blue, text: "Page 3")
}
.tabViewStyle(.page) // Enables swipe paging
.indexViewStyle(.page(backgroundDisplayMode: .always))
.ignoresSafeArea()// Dots indicator
}
}
Does anyone have any documentation for how to achieve the floating search tab item in UIKit apps that use UITabBarController?
The Liquid Glass UIKit video had code for minimizing the tab bar on scroll down, but I didn't see anything on keeping the search button locked to the bottom trailing edge (as in this screenshot below).
Hello, I have been trying for some time to change the color of native UITabBar in UITabBarController through UITabBarAppearance, but nothing works and the text is still black in the Xcode Beta 3 on iPadOS 26 while it works correctly in the previous OS versions.
Here is the code:
let color = UIColor.white
let stackedAppearance = UITabBarItemAppearance()
stackedAppearance.normal.iconColor = color
stackedAppearance.normal.titleTextAttributes = [
.foregroundColor: color
]
stackedAppearance.selected.iconColor = color
stackedAppearance.selected.titleTextAttributes = [
.foregroundColor: color
]
let inlineAppearance = UITabBarItemAppearance()
inlineAppearance.normal.iconColor = color
inlineAppearance.normal.titleTextAttributes = [
.foregroundColor: color
]
inlineAppearance.selected.iconColor = color
inlineAppearance.selected.titleTextAttributes = [
.foregroundColor: color
]
let tabAppearance = UITabBarAppearance()
tabAppearance.compactInlineLayoutAppearance = inlineAppearance
tabAppearance.inlineLayoutAppearance = inlineAppearance
tabAppearance.stackedLayoutAppearance = stackedAppearance
UITabBar.appearance().standardAppearance = tabAppearance
UITabBar.appearance().scrollEdgeAppearance = tabAppearance