Error: "Attrubute can only be applied to types not declarations" on line 2 : @unchecked
@unchecked
enum ReminderRow : Hashable, Sendable {
case date
case notes
case time
case title
var imageName : String? {
switch self {
case .date: return "calendar.circle"
case .notes: return "square.and.pencil"
case .time: return "clock"
default : return nil
}
}
var image : UIImage? {
guard let imageName else { return nil }
let configuration = UIImage.SymbolConfiguration(textStyle: .headline)
return UIImage(systemName: imageName, withConfiguration: configuration)
}
var textStyle : UIFont.TextStyle {
switch self {
case .title : return .headline
default : return .subheadline
}
}
}
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Posts under UIKit tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a UIKit app with a custom navigation controller. I want my view title to go up into the navigation bar when the user scrolls down the screen. It looks like UIScrollEdgeElementContainerInteraction should do what I want, but I am having trouble using it.
Below is a sample, where a header view represents a title. I added the interaction to the header view, but it seems to have no effect. Am I missing a step? Perhaps I misunderstand what this is supposed to do, or perhaps I do not understand the preconditions to make this work.
I am hoping someone can tell me what I am doing wrong, or point me to some working sample code.
Thank you.
John
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var headerView: UIVisualEffectView!
var tableView: UITableView!
var interaction: UIScrollEdgeElementContainerInteraction!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView = UITableView()
self.tableView.translatesAutoresizingMaskIntoConstraints = false
self.tableView.topEdgeEffect.style = .soft
self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.view.addSubview(self.tableView)
self.view.addConstraints([
self.tableView.topAnchor.constraint(equalTo: self.view.topAnchor),
self.tableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
self.tableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
self.tableView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
])
self.headerView = UIVisualEffectView(effect: UIGlassEffect(style: .regular))
self.headerView.translatesAutoresizingMaskIntoConstraints = false
self.headerView.backgroundColor = .green
self.view.addSubview(self.headerView)
self.view.addConstraints([
self.headerView.topAnchor.constraint(equalTo: self.view.topAnchor),
self.headerView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
self.headerView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
self.headerView.heightAnchor.constraint(equalToConstant: 100.0),
])
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "my text"
self.headerView.contentView.addSubview(label)
self.headerView.contentView.addConstraints([
label.centerXAnchor.constraint(equalTo: self.headerView.contentView.centerXAnchor),
label.centerYAnchor.constraint(equalTo: self.headerView.contentView.centerYAnchor),
])
self.interaction = UIScrollEdgeElementContainerInteraction()
self.interaction.scrollView = self.tableView
self.interaction.edge = .top
self.headerView.addInteraction(self.interaction)
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "row \(indexPath.row + 1)"
return cell
}
}
iPadOS 26, dark mode
Open Safari
Search for anything or open a website that has white background
Kill Safari
Open Safari again
I still can reproduce it with Safari on iPadOS 26.0.1
This issue also happens to my app when opening a HTML/JS on WKWebView with white background while using dark mode. I did send a feedback ticket when using iPadOS 26 beta but havent seen any reply. This is my first time sending a feedback so I dont know if Apple would reply or not.
I recently was thinking about which is the best format to use for my little icons in the app, and was considering the performance of PNG versus SVG . I know that PNG decoders are hardware accelerated and parallelized, and the rendering is as simple as placing the pixels on the screen.
On the other hand, SVG requires computation to determine the placement of pixels based on mathematical equations.
Considering this, my current assumption is that PNG is faster to render than SVG. However, if SVG is also hardware-accelerated, it could alter the situation, although this may not be the case.
When a TextField is set to a rightToLeft layout, it gets strange and unnecessary padding on the left side. This pushes the text away from the edge. This issue doesn't occur in the leftToRight layout, where the text aligns correctly. Does anyone know how to get rid of this extra padding?
Environment:
Xcode version: 26.0.1
Device: iPhone 13
iOS version: 26.0
Code:
struct ContentView: View {
@State var textInput: String = ""
var body: some View {
VStack {
Text("rightToLeft")
TextField("placeholder", text: $textInput)
.background(Color.red)
.environment(\.layoutDirection, .rightToLeft)
Text("leftToRight")
TextField("placeholder", text: $textInput)
.background(Color.red)
.environment(\.layoutDirection, .leftToRight)
}
.padding()
}
}
I've got an iOS app with a custom top toolbar view that uses a UIScrollEdgeElementContainerInteraction to achieve the iOS 26 progressive blur background. It's over top of a web view, and I've set the top edge effect style on its scroll view to .hard so the toolbar's edges are more defined.
I'm noticing that the blur doesn't extend fully to the bottom edge of the toolbar, and I'm curious to know if this is a bug or expected behavior. If the latter, what exactly are the details of what's expected? What determines the bottom extent of the blur?
I've got this result in a sample project on iOS 26.0. The white border is the label, and the red border is the title bar view itself. Note that the Daring Fireball logo visible inside the bounds of the bar view, and is cut off at the bottom edge of the label.
This is the code from the demo app that produced the screenshot.
let config = WKWebViewConfiguration()
let webView = WKWebView(frame: .zero, configuration: config)
self.view.addSubview(webView)
webView.translatesAutoresizingMaskIntoConstraints = false
webView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true;
webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true;
webView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true;
webView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true;
webView.scrollView.topEdgeEffect.style = .hard
webView.load(URLRequest(url: URL(string: "https://daringfireball.net")!))
let barView = UIView()
self.view.addSubview(barView)
barView.translatesAutoresizingMaskIntoConstraints = false
barView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true;
barView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
barView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
let edgeEffect = UIScrollEdgeElementContainerInteraction()
edgeEffect.scrollView = webView.scrollView
edgeEffect.edge = .top
barView.addInteraction(edgeEffect)
barView.layer.borderColor = UIColor.red.cgColor
barView.layer.borderWidth = 1
let titleLabel = UILabel()
barView.addSubview(titleLabel)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.leftAnchor.constraint(equalTo: barView.leftAnchor).isActive = true
titleLabel.rightAnchor.constraint(equalTo: barView.rightAnchor).isActive = true
titleLabel.bottomAnchor.constraint(equalTo: barView.bottomAnchor, constant: -20).isActive = true
titleLabel.topAnchor.constraint(equalTo: barView.safeAreaLayoutGuide.topAnchor, constant: 8).isActive = true
titleLabel.textAlignment = .center
titleLabel.text = "Title Here"
titleLabel.layer.borderColor = UIColor.green.cgColor
titleLabel.layer.borderWidth = 1
We are trying to use UITabAccessory to persist information across Tabs. When a new view onto the stack we hide the tab bar. It appears that UITabAccessory does not hide when the TabBar is hidden. Is there a way to hide/present it along with the TabBar?
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?
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?
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
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.
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
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;
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?
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?
I've updated test device to iOS 26.1 (23B5059e) and it looks like topColumnForCollapsingToProposedTopColumn isn't being called.
The code has been fine up until iOS 26.1. Is that a UIKit issue or shall I find another way to get my splitview to show the primary view as default?
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")
}
}
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:
When I tried this, the app crashed immediately with a requirement to use NSTextContentStorage subclass
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.