Construct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.

Posts under UIKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

UIScrollEdgeElementContainerInteraction uses wrong mix-in color over WKWebView on iOS 26.1
There seems to be a regression in the behavior of UIScrollEdgeElementContainerInteraction on iOS 26.1 when it's over a WKWebView. If the web view's scroll view's topEdgeEffect.style is changed to .hard and then back to .soft, it will stop tracking the color of the content underneath it and use the wrong-mix in color in its blur. I've filed this as FB20655398. Here's some sample code to illustrate the issue. The test.html file being loaded is just a bunch of div elements with lorem ipsum. private var webView: WKWebView? = nil override func viewDidLoad() { super.viewDidLoad() let config = WKWebViewConfiguration() let webView = WKWebView(frame: .zero, configuration: config) webView.navigationDelegate = self self.view.addSubview(webView) webView.autoPinEdgesToSuperviewEdges() webView.isInspectable = true self.webView = webView let url = Bundle.main.url(forResource: "test", withExtension: "html")! webView.loadFileURL(url, allowingReadAccessTo: Bundle.main.bundleURL) let blurView = UIView() self.view.addSubview(blurView) blurView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .bottom) let label = UILabel() label.text = "This is a title bar" blurView.addSubview(label) label.autoAlignAxis(toSuperviewAxis: .vertical) label.autoPinEdge(toSuperviewEdge: .bottom, withInset: 8) label.autoPinEdge(toSuperviewSafeArea: .top, withInset: 8) let interaction = UIScrollEdgeElementContainerInteraction() interaction.scrollView = webView.scrollView interaction.edge = .top blurView.addInteraction(interaction) self.webView?.scrollView.topEdgeEffect.style = .hard DispatchQueue.main.asyncAfterUnsafe(deadline: .now() + .seconds(2)) { self.webView?.scrollView.topEdgeEffect.style = .soft } registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, previousTraitCollection: UITraitCollection) in self._updateWebViewColors() } } private func _updateWebViewColors() { let dark = self.traitCollection.userInterfaceStyle == .dark let text = dark ? "#FFFFFF" : "#000000" let bg = dark ? "#000000" : "#FFFFFF" let js = "document.body.style.color = '\(text)';\ndocument.body.style.backgroundColor = '\(bg)';" self.webView?.evaluateJavaScript(js) { res, err in if let err { print("JS error: \(err)") } } } If you run that, then change the system them to dark mode, you get this. Has anyone else seen this before? Know how to work around it?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
81
2w
UIMenuElementAttributesKeepsMenuPresented not working when Glass Grouping changes
I'm working on a UIBarButtonItem that is supposed to be a filter button - it shows a menu in which the user can (un)check menu items. Using the UIMenuElementAttributesKeepsMenuPresented attribute on the UIActions prevents the menu to hide after the user clicks an item. The button is put alongside another button as the leftBarButtonItems of my navigation item. In iOS 26 they are grouped into a single glass container automatically. Now when the user starts filtering, I want to highlight the UIBarButton item to signal to the user that the filter is active (similar to what Apple does in the Mail app). I do that by setting the UIBarButtonItemStyle to prominent. Now that works too, but it causes the automatic glass grouping to break up and the menu to hide. I'm fine with the grouping to break up, but the menu shouldn't hide. Is this a bug or can this be prevented somehow?
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
112
2w
What is the standard process of subclassing NSTextLocation?
Cannot find any guidance in the forums and Developer Doc, the WWDC session Meet TextKit2 says this protocol is served for any location type espacially useful when the underlying doc model is not linear. But when I try to subclass the NSTextLocation with my own type to define a more structured location rather than a linear one, also with my own NSTextContentManager subclass implementation, I keep receiving the system internal Location model like NSCountableTextLocation compare to my location which cause the app to crash. -[NSCountableTextLocation compare:] receiving unmatching type <MarkdownTK2.ChildIndexPathLocation: 0x9b2402aa0> In my own NSTextContentManager subclass: public override func offset( from: any NSTextLocation, to: any NSTextLocation ) -> Int { this method will also both receive my own location and some times receiving the system defined location that I can not calculate the offset then just return zero. The doc only says If you provide your own implementation of the NSTextLocation protocol to manage locations in your content, subclass NSTextContentManager and implement your own storage object to support those locations. OS Development environment: Xcode 26.0, macOS 26.0 Run-time configuration: macOS 26.0
3
0
188
2w
iOS 26 Modal View Controller with Transparent Background
Prior to iOS 26, this successfully gave me a modal view with a transparent background: let settingsVC = MySettingsViewController() settingsVC.modalPresentationStyle = .automatic //settingsVC.modalPresentationStyle = .overCurrentContext self.present(settingsVC, animated: true, completion: { } MySettingsViewController: self.view.backgroundColor = UIColor(white: 0, alpha: 0.5) Now in iOS 26, modal view is presented in a opaque grey background.
Topic: Design SubTopic: General Tags:
0
0
570
2w
PhotosUI does not build with UIKit and WidgetKit in XCode26
To reproduce this bug create a new Xcode Project for IOS choose UIKit. In the app delegate add the following lines. As you can see in the above image . Line 19 with the initialization of PHPickerViewController has no compilation failure. Now lets add import WidgetKit As soon as widgetKit is imported a compiler error is thrown which is PHPickerViewController is not in scope. This worked with Xcode 16.4 It was possible to have a swift file with both WidgetKit implementations and PhotosUI implementations. This behavior has changed in Xcode 26/26.0.1 . Does anybody know why this happens , could not find any clues within the different versions of documentations. P.S Found a work around which raises further questions Adding import SwiftUI fixes this problem , I am genuinely curious on how this is happening on a compiler level. LINKS To my previously published post :https://developer.apple.com/forums/thread/804059
0
3
88
2w
iOS26 UINavigationBar small title not visible when scroll
I have an App with a UITabBarController. When one of the Tabs is selected then it presents a UINavigationController. This in turn presents a UIViewController to start with. (Call it myViewVC) myViewVC has a UITableView. This is the only subview of myViewVC. When I scroll I expect the UINavigationBar to collapse from a large Title to a small title. But instead I see no small title. This all worked fine in iOS18.x I have tried various things suggested on forums and by AI and none of these have fixed the problem I have set both self.navigationItem.title = @"My VC"; and self.navigationItem.largeTitle = @"My VC (New in iOS26) It was suggested that I tie the UITableView constraints to the top of the view rather than the safe area. That did not help. I have removed any custom appearance settings for the UINavigationBar. That did not help. I also tried to add this line but it did not help myTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
90
2w
iOS26 UINavigationController swipe from middle on maps causing issue
I have a UINavigation controller which on the second viewController has a Google Map view. In iOS 18 you would navigate normally around the map, and swipe your finger from the left side of the screen to move the map, this worked correctly. However, in iOS 26 swiping from left to right from anywhere but the far right side of the screen will cause the UI to try to pop the viewController. This does not happen when I add Apple Maps or other map frameworks to the VC. Is there a way to disable the "swipe from middle" in iOS 26?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
95
2w
UISplitView with "sidebar" and Liquid Glass
I have a couple of (older) UIKit-based Apps using UISplitViewController on the iPad to have a two-column layout. I'm trying to edit the App so it will shows the left column as sidebar with liquid glass effect, similar to the one in the "Settings" App of iPadOS 26. But this seems to be almost impossible to do right now. "out of the box" the UISplitViewController already shows the left column somehow like a sidebar, with some margins to the sides, but missing the glass effect and with very little contrast to the background. If the left column contains a UITableViewController, I can try to get the glass effect this way within the UITableViewController: tableView.backgroundColor = .clear tableView.backgroundView = UIVisualEffectView(effect: UIGlassContainerEffect()) It is necessary to set the backgroundColor of the table view to the clear color because otherwise the default background color would completely cover the glass effect and so it's no longer visible. It is also necessary to set the background of all UITableViewCells to clear. If the window is in the foreground, this will now look very similar to the sidebar of the Settings App. However if the window is in the back, the sidebar is now much darker than the one of the Settings App. Not that nice looking, but for now acceptable. However whenever I navigate to another view controller in the side bar, all the clear backgrounds destroy the great look, because the transition to the new child controller overlaps with the old parent controller and you see both at the same time (because of the clear backgrounds). What is the best way to solve these issues and get a sidebar looking like the one of the Settings App under all conditions?
4
1
383
3w
Menu presentation in UIHostingController issues
Looking to see if anyone has experienced this issue, and is aware of any workarounds. With an app migrating towards SwiftUI Views but still using UIKit for primary navigation, my app makes use of UIHostingController to push SwiftUI Views onto a UINavigationController stack in a lot of areas. With iOS 26, I notice that SwiftUI's Menu view really struggles to present when contained in a UIHostingController. An error is logged to the console on presentation, and depending on the UI, the Menu won't present inside of it's container, or will jump around the screen. The bug, it seems is based in a private class UIReparentingView and I am curious if anyone has found a work around for this issue. The error reported is: Adding '_UIReparentingView' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead. The simplest way to see this issue is to create a new storyboard based project. From the ViewController present a UIHostingController with a SwiftUI view that has a Menu and then simply tap to open the Menu. Thanks for any input!
6
2
311
3w
iOS26 UISearchbar and UISearchController cancellation issues
Is the Cancel button intentionally removed from UISearchBar (right side)? Even when using searchController with navigationItem also. showsCancelButton = true doesn’t display the cancel button. Also: When tapping the clear ("x") button inside the search field, the search is getting canceled, and searchBarCancelButtonClicked(_:) is triggered (Generally it should only clear text, not cancel search). If the search text is empty and I tap outside the search bar, the search is canceled. Also when I have tableview in my controller(like recent searches) below search bar and if I try to tap when editing started, action is not triggered(verified in sample too). Just cancellation is happening. In a split view controller, if the search is on the right side and I try to open the side panel, the search also gets canceled. Are these behaviors intentional changes, beta issues, or are we missing something in implementation?
8
1
597
3w
List's shadow flickering
When Home tab opened, there is some white shadow on the bottom and the top sides of the list. But when switching to other tab or return to Home tab this shadow disappearing for a second and appearing again. Actual for iOS 26.0.1 on simulator and on real device. Below is short example code that can reproduce issue. When change let pages = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal) to let pages = UIPageViewController(transitionStyle: .pageCurl, navigationOrientation: .horizontal) issue is not reproduced. import SwiftUI @main struct GlassTestApp: App { var body: some Scene { WindowGroup { MainView() .ignoresSafeArea() } } } struct MainView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UITabBarController { let controller = UITabBarController() let home = Home() home.tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "house"), tag: 1) let settings = UIHostingController(rootView: Settings()) settings.tabBarItem = UITabBarItem(title: "Settings", image: UIImage(systemName: "gearshape"), tag: 2) controller.viewControllers = [home, settings] return controller } func updateUIViewController(_ uiViewController: UITabBarController, context: Context) { } } class Home: UINavigationController { init() { let pages = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal) pages.setViewControllers([UIHostingController(rootView: Page1())], direction: .forward, animated: false) super.init(rootViewController: pages) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } struct Page1: View { var body: some View { List { ForEach(1...100, id: \.self) { Text("\($0)") } } .listStyle(.plain) } } struct Settings: View { var body: some View { Text("Settings") } }
4
0
231
3w
iOS 26 Liquid Glass - Without any Blur - Possible?
let glassView = UIVisualEffectView(effect: UIGlassEffect(style: .clear)) glassView.frame = CGRect(x: 100, y: 200, width: 200, height: 400) self.view.addSubview(glassView) Though UIGlassEffect has two variants: .regular and .clear, even the clear one has some blur on the background. Is there a way to do get absolute no blur? Edges still have the glass effect. Apple does this in two places: Camera app: Text magnifier:
Topic: Design SubTopic: General Tags:
0
0
622
3w
Xcode26 build app with iOS26, UISplitViewController UI issue
Our project using UISplitViewController as the root view controller for whole app. And when using the xocde26 to build app in iOS26, the layout of page is uncorrect. for iPhone, when launch app and in portrait mode, the app only show a blank page: and when rotate app to landscape, the first view controller of UISplitViewController's viewControllers will float on second view controller: and this float behavior also happens in iPad: below is the demo code: AppDelegate.swift: import UIKit @main class AppDelegate: UIResponder, UIApplicationDelegate { let window: UIWindow = UIWindow() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let vc = SplitViewController(primary: TabBarViewController(), secondary: ViewController()) window.rootViewController = vc window.makeKeyAndVisible() return true } } SplitViewController: import UIKit class SplitViewController: UISplitViewController { init(primary: UIViewController, secondary: UIViewController) { super.init(nibName: nil, bundle: nil) preferredDisplayMode = .oneBesideSecondary presentsWithGesture = false delegate = self viewControllers = [primary, secondary] } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() } } extension SplitViewController: UISplitViewControllerDelegate { } TabBarViewController.swift: import UIKit class FirstViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .red tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "house"), tag: 0) } } class SecondViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .purple tabBarItem = UITabBarItem(title: "Setting", image: UIImage(systemName: "gear"), tag: 1) } } class TabBarViewController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() let firstVC = FirstViewController() let secondVC = SecondViewController() tabBar.backgroundColor = .orange viewControllers = [firstVC, secondVC] } } ViewController.swift: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemPink } } And I have post a feedback in Feedback Assistant(id: FB18004520), the demo project code can be found there.
4
1
564
3w
UIBarButtonItem alignment in UIToolbar on iOS 26 in UIDesignRequiresCompatibility mode
The screenshot is showing the same app deployed using Xcode version 26.0 beta 4 (17A5285i) on iOS 18.5 and on iOS 26.0. In iOS 26 beta 4 on the right the spacing of the UIBarButtonItem elements does not look good: The buttons are created like so: colorButtonText = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"paintbrush"] style:UIBarButtonItemStylePlain target:self action:@selector(drawingActionColor:)]; //... [drawingToolbarText setItems:@[colorButtonText, ...]]; Is this a known issue with the current iOS 26? Am I doing something wrong?
3
2
344
3w
UI resizing / realigning issue in iOS 26 device building in xcode 26
In our app we launch landscape only player view controller from portrait only view controller. This is done using present(playerViewController, animated:true) and it is dismissed using dismiss() api. This is working fine till iOS 18 but broken in iOS 26. Now when presenting the presented viewcontrollers UI is realigning / resizing after the view is visible and while dismissing the presenting view controller is realigning after the view is visible. Anyone else seeing it or how to fix this?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
224
3w
Fatal safeAreaInsets Error on Certain iOS/iPadOS 26 Devices
Fatal safeAreaInsets Error on Certain iOS/iPadOS 26 Devices On certain devices that have updated to iOS/iPadOS 26, the safeAreaInsets value is displayed incorrectly when rotating. On the iPhone SE3, the safeAreaInsets.top value is displayed inverted when rotating. It should return 20.0 when rotated vertically and 0.0 when rotated horizontally. Currently, the value is reversed. (0.0 when rotated horizontally and 20.0 when rotated vertically.) On iPad Pro devices, the safeAreaInsets.top value is always returned as 0.0 when the app is first launched. (This issue is believed to occur on all iPad devices, including the iPad Pro.) If the user subsequently rotates the iPad, the safeAreaInsets value is returned correctly. On the iPhone 17 with dynamic islands, the safeAreaInsets value is displayed correctly. My guess is that all devices running iOS/iPadOS 26 without dynamic islands will experience an issue where the safeAreaInsets value is displayed incorrectly. This issue occurs when building with Xcode 26. Apple, please issue an OS update as soon as possible. Or, if this is an Xcode issue, please update Xcode.
4
2
270
3w