Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

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

Update Widget Every Minute
Is this not possible? I have a simple text view that shows the time, but it doesn't stay in sync with the time. I've tried to use a timer like I do inside the app, but that didn't work. I tried TimelineView with it set to every minute, and that didn't work. I tried to use the dynamic date using Text(date, style: ) and that didn't work. I looked it up and apparently it's a limitation to WidgetKit, however, I don't understand how the Apple Clock widget can have a moving second hand that updates properly. Do I just need to add a bunch of entries in the TimelineProvider? Right now, it's just the default that gets loaded when you create a Widget extension. func timeline(for configuration: SingleClockIntent, in context: Context) async -> Timeline<SingleClockEntry> { var entries: [SingleClockEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() for hourOffset in 0 ..< 5 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SingleClockEntry(date: entryDate, configuration: configuration) entries.append(entry) } return Timeline(entries: entries, policy: .atEnd) } EDIT: This code below seems to be working. Can someone confirm if it will continue to work, or will it eventually stop updating? func timeline(for configuration: SingleClockIntent, in context: Context) async -> Timeline<SingleClockEntry> { var entries: [SingleClockEntry] = [] let calendar = Calendar.current let current = Date() // Get the next minute let secondEntryDate = calendar.nextDate(after: current, matching: DateComponents(second: 0), matchingPolicy: .strict, direction: .forward)! entries.append(SingleClockEntry(date: current, configuration: configuration)) // Adds current time entries.append(SingleClockEntry(date: secondEntryDate, configuration: configuration)) // Adds next minute after current time // Add an entry every min for the next 30 minutes for offset in 0..<30 { let entryDate = Calendar.current.date(byAdding: .minute, value: offset, to: secondEntryDate)! let entry = SingleClockEntry(date: entryDate, configuration: configuration) entries.append(entry) } return Timeline(entries: entries, policy: .atEnd) }
0
0
9
1h
Unable to apply tinted glass effect to toolbar buttons in iOS 26
I'm trying to apply a tinted glass effect to toolbar buttons in iOS 26, similar to what was shown in the WWDC25 videos, but none of the approaches I've tried produce the translucent tinted glass effect. My code structure: .toolbar { ToolbarItem(placement: .navigationBarTrailing) { TrailingToolbarContent( selectedTab: $selectedTab, showingAddBeneficiary: $showingAddBeneficiary ) } } private struct TrailingToolbarContent: View { @Binding var selectedTab: Int @Binding var showingAddBeneficiary: Bool @EnvironmentObject private var settingsViewModel: SettingsViewModel var body: some View { switch selectedTab { case 1: if #available(iOS 26.0, *) { Button(action: { showingAddBeneficiary = true }) { Image(systemName: "plus") } // What I've tried: // .tint(Color("accentPrimary")) // Only changes icon color // .glassEffect(.regular.tint(Color("accentPrimary"))) // No effect // .buttonStyle(.glass).tint(Color("accentPrimary")) // No tint, but orange background // .buttonStyle(.borderedProminent).tint(Color("accentPrimary")) // Works but seems opaque, not glass } // ... other cases } } } What's the correct way to achieve tinted glass effects on toolbar buttons?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
14
4h
Keyboard fails to appear after converting app to UIScene lifecycle
Getting this in log any time I try to start typing anything into a UITextField: First responder issue detected: non-key window attempting reload - allowing due to manual keyboard (first responder window is &lt;UIWindow: 0x10e016880; frame = (0 0; 1133 744); gestureRecognizers = &lt;NSArray: 0x10ba53850&gt;; backgroundColor = &lt;UIDynamicProviderColor: 0x108563370; provider = &lt;NSMallocBlock: 0x11755bd50&gt;&gt;; layer = &lt;UIWindowLayer: 0x10ba84190&gt;&gt;, key window is ) I'm suspicious of the empty "key window is" field. Everything else in the app is working fine. But I cannot figure out why this fails to show the keyboard, and no keyboard notifications are being received by the app. What could it be?
0
0
21
19h
Slideshow / Gallery / Photos app View
How can I create a view that is like the one in the Photos app where you can select an item and it fills the window, then you can drag / swipe between items in that view? I have a working prototype, and it works for photos. But once I get to a video, the gesture no longer works.
2
0
24
21h
Detect when app window is being moved
Is there a way to detect when your apps (or any app I guess) is being moved by the user clicking and dragging the main window around the desktop at all? I'm trying to find out if there's a way I can find out if a window is being clicked and dragged and whether there's certain triggers to the movement a little bit like shaking an iPhone with Shake to Undo. Thanks
0
0
17
23h
ViewThatFits and Text Truncation
I'm using ViewThatFits to handle different screen sizes as well as the orientation of the phone. Essentially, I have a smaller view that should only be used in portrait mode on the phone and a larger view that should be used in every other instance. The issue is that both of those views have a Text view that is bound to a String within a SwiftData model. If the String is too long the ViewThatFits considers that when choosing the appropriate subview. This results in a list of items where most items use one view while one or more may use the other view. It would be great if there was a modifier that could be applied to the Text view that resulted in the ViewThatFits ignoring it when determining the appropriate subview. Until such a modifier is available, has anyone come up with creative ways around this?
1
0
21
1d
Screenshot preventing
I’d like to know if Apple currently supports any public API or entitlement for blocking in-app screenshots on iOS. If no such API exists, what is the officially recommended approach for App Store apps to prevent or react to screenshots of sensitive content in a banking app? I have tried using a hidden UITextField with isSecureTextEntry = true and observing UIApplication.userDidTakeScreenshotNotification, but these methods do not block the initial screenshot. Could you please advise how to block screenshots in my app?
Topic: UI Frameworks SubTopic: UIKit
4
0
43
1d
Xcode26 build app with iOS26, UITabBarController set CustomTabBar issue
Our project using UITabBarController and set a custom tabbar using below code: let customTabBar = CustomTabBar(with: dataSource) setValue(customTabBar, forKey: "tabBar") But when using Xcode 26 build app in iOS 26, the tabbar does not show: above code works well in iOS 18: 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 { window.rootViewController = TabBarViewController() window.makeKeyAndVisible() return true } } CustomTabBar.swift: import UIKit class CustomTabBar: UITabBar { class TabBarModel { let title: String let icon: UIImage? init(title: String, icon: UIImage?) { self.title = title self.icon = icon } } class TabBarItemView: UIView { lazy var titleLabel: UILabel = { let titleLabel = UILabel() titleLabel.translatesAutoresizingMaskIntoConstraints = false titleLabel.font = .systemFont(ofSize: 14) titleLabel.textColor = .black titleLabel.textAlignment = .center return titleLabel }() lazy var iconView: UIImageView = { let iconView = UIImageView() iconView.translatesAutoresizingMaskIntoConstraints = false iconView.contentMode = .center return iconView }() private var model: TabBarModel init(model: TabBarModel) { self.model = model super.init(frame: .zero) setupSubViews() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setupSubViews() { addSubview(iconView) iconView.topAnchor.constraint(equalTo: topAnchor).isActive = true iconView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true iconView.widthAnchor.constraint(equalToConstant: 34).isActive = true iconView.heightAnchor.constraint(equalToConstant: 34).isActive = true iconView.image = model.icon addSubview(titleLabel) titleLabel.topAnchor.constraint(equalTo: iconView.bottomAnchor).isActive = true titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true titleLabel.heightAnchor.constraint(equalToConstant: 16).isActive = true titleLabel.text = model.title } } private var dataSource: [TabBarModel] init(with dataSource: [TabBarModel]) { self.dataSource = dataSource super.init(frame: .zero) setupTabBars() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func sizeThatFits(_ size: CGSize) -> CGSize { var sizeThatFits = super.sizeThatFits(size) let safeAreaBottomHeight: CGFloat = safeAreaInsets.bottom sizeThatFits.height = 52 + safeAreaBottomHeight return sizeThatFits } private func setupTabBars() { backgroundColor = .orange let multiplier = 1.0 / Double(dataSource.count) var lastItemView: TabBarItemView? for model in dataSource { let tabBarItemView = TabBarItemView(model: model) addSubview(tabBarItemView) tabBarItemView.translatesAutoresizingMaskIntoConstraints = false tabBarItemView.topAnchor.constraint(equalTo: topAnchor).isActive = true tabBarItemView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true if let lastItemView = lastItemView { tabBarItemView.leadingAnchor.constraint(equalTo: lastItemView.trailingAnchor).isActive = true } else { tabBarItemView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true } tabBarItemView.widthAnchor.constraint(equalTo: widthAnchor, multiplier: multiplier).isActive = true lastItemView = tabBarItemView } } } TabBarViewController.swift: import UIKit class NavigationController: UINavigationController { override func viewDidLoad() { super.viewDidLoad() } } class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .red navigationItem.title = "Home" } } class PhoneViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .purple navigationItem.title = "Phone" } } class PhotoViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .yellow navigationItem.title = "Photo" } } class SettingViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .green navigationItem.title = "Setting" } } class TabBarViewController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() let homeVC = HomeViewController() let homeNav = NavigationController(rootViewController: homeVC) let phoneVC = PhoneViewController() let phoneNav = NavigationController(rootViewController: phoneVC) let photoVC = PhotoViewController() let photoNav = NavigationController(rootViewController: photoVC) let settingVC = SettingViewController() let settingNav = NavigationController(rootViewController: settingVC) viewControllers = [homeNav, phoneNav, photoNav, settingNav] let dataSource = [ CustomTabBar.TabBarModel(title: "Home", icon: UIImage(systemName: "house")), CustomTabBar.TabBarModel(title: "Phone", icon: UIImage(systemName: "phone")), CustomTabBar.TabBarModel(title: "Photo", icon: UIImage(systemName: "photo")), CustomTabBar.TabBarModel(title: "Setting", icon: UIImage(systemName: "gear")) ] let customTabBar = CustomTabBar(with: dataSource) setValue(customTabBar, forKey: "tabBar") } } And I have post a feedback in Feedback Assistant(id: FB18141909), the demo project code can be found there. How are we going to solve this problem? Thank you.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
40
1d
encounter memory leak for SVG image
I have a memory leak for SVG image that located in Assets.xcassets file when using SwiftUI Image, but when I use UIImage then convert it to SwiftUI Image the issue is not found. import SwiftUI struct ContentView: View { var body: some View { NavigationStack { VStack { NavigationLink("Show", destination: SecondView()) } .padding() } } } struct SecondView: View { @Environment(\.dismiss) var dismiss var body: some View { NavigationStack { VStack { IM.svgImage .resizable() .scaledToFit() .frame(width: 200, height: 200) Button("Dismiss") { dismiss() } } } } } enum IM { static let testImage: Image = "test_image".image static let svgImage: Image = "svgImage".image } extension String { var image: Image { Image(self) // Memory leak } var imageFromUIImage: Image { guard let uiImage = UIImage(named: self) else { return Image(self) } return Image(uiImage: uiImage) // No Memory leak } } Environment that produces the issue: Xcode: 16.2 Simulator: iPhone 15 Pro (iOS 17.5)
1
0
21
1d
Can't display image in SwiftUI
I'm trying to display my apps icon within my app and it's not working. It displays a blank space instead and I don't understand why this is happening. I tried creating a new image (just a normal image, not an 'App Icon' image set) and have this code: Image("AppIcon") .resizable() .aspectRatio(contentMode: .fit) .frame(width: 48) .cornerRadius(10) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(Color.black.opacity(0.1), lineWidth: 1) ) For some strange reason it's not displaying that either. The image name is correct. It's showing a blank white box.
2
0
31
1d
SwiftUI lifecycle / CarPlay / data model
Is there a way to share a SwiftUI App's @Observable model into a CPTemplateApplicationSceneDelegate ? Is there an incantation to go from the UIApplicationDelegate via @UIApplicationDelegateAdaptor to the UISceneDelegate for CarPlay via a userInfo? I can't seem to figure it out. Otherwise I have to use a shared global, and I'd prefer not to have to do it this way. Any ideas? Thanks!
2
0
43
2d
iOS 26 Liquid Glass - How to achieve separate glass backgrounds for multiple leading toolbar items?
I'm updating my app for iOS 26's new Liquid Glass design and encountering unexpected behavior with toolbar items. I want to display multiple buttons on the leading side of the navigation bar, each with its own glass background (similar to how LandmarkDetailView shows separate glass backgrounds for its toolbar items). Current Behavior: When using .navigationBarLeading placement for multiple ToolbarItems, they all group under ONE glass background When using NO placement (like in Apple's LandmarkDetailView example), items get separate glass backgrounds but appear on the RIGHT side Using different leading placements (.topBarLeading vs .navigationBarLeading) still groups them together What I've Tried: swift// Attempt 1: All items with same placement - they group together .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: {}) { Image(systemName: "dollarsign.circle") } } ToolbarItem(placement: .navigationBarLeading) { Button(action: {}) { Image(systemName: "qrcode") } } } // Attempt 2: No placement - separate glass but wrong position .toolbar { ToolbarItem { Button(action: {}) { Image(systemName: "dollarsign.circle") } } ToolbarSpacer(.fixed) ToolbarItem { Button(action: {}) { Image(systemName: "qrcode") } } ToolbarSpacer(.flexible) } // Attempt 3: Different placements - still groups .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: {}) { Image(systemName: "dollarsign.circle") } } ToolbarItem(placement: .navigationBarLeading) { Button(action: {}) { Image(systemName: "qrcode") } } } Environment: Xcode 26 Beta iOS 26.0 Beta Using NavigationView (also tried NavigationStack) This is a root view (no back button) Questions: Is grouping of same-placement toolbar items the intended Liquid Glass behavior? How can I achieve separate glass backgrounds for multiple leading toolbar items? Why do items without placement appear on the right in a root view? Is there new API or guidance for toolbar layouts in iOS 26? I've studied the LandmarkDetailView example from Apple, but it uses no placement and relies on being a detail view with a back button. My use case is a root navigation view. Any guidance would be appreciated!
Topic: UI Frameworks SubTopic: SwiftUI
2
0
65
2d
Lack of API to access scrubber preview time in AVPlayerViewController (scrubbingTime)
Hi everyone, I'm working with AVPlayerViewController in a tvOS/iOS app and ran into a limitation that I believe some developers face. When using player.currentItem?.currentTime(), we only get the playback time—which is fine while the video is playing. But when the player is paused and the user drags the scrubber, there's no public API to get the time that is currently being previewed under the scrubber thumb (stick), but there's no way to read it programmatically. This becomes a problem when trying to show thumbnail previews or display metadata tied to the scrubbed position.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
1
30
2d
iOS26 beta ToolbarItem with placement to principal width is not fill to screen
I’m trying to add a TextField to the toolbar using .principal placement, and I want it to either fill the screen width or expand based on the surrounding content. However, it’s not resizing as expected — the TextField only resizes correctly when I provide a hardcoded width value. This behavior was working fine in previous versions of Xcode, but seems to be broken in Xcode 26. Not sure if this is an intentional change or a bug. i am using iOS26 beta and Xcode 26 beta struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() .toolbar { ToolbarItem(placement: .principal) { HStack { TextField("Search", text: .constant("")) .textFieldStyle(.roundedBorder) .frame(maxWidth: .infinity) // .frame(width: 300) Button("cancel") { } } .frame(maxWidth: .infinity) } } } } #Preview { NavigationView { ContentView() } }
0
0
43
2d