I am trying to understand if what I am seeing is expected behavior or not with the following UIKit components.
1.I have a view controller "A" embedded in a navigation controller (part of a multi-step flow). Large titles are active on this navigation controller.
In this view controller "A", I have a container view that contains another view controller "B" (I want to reuse the contents of B in other flows)
Inside view controller "B" I have a UICollectionView using a diffable data source.
When you load view controller "A" it appears to work fine. My collection view loads data, I see a nice list and when I scroll it...
... the expectation is it scrolls inside it's container and has no impact on the parent controller "B"
However, the navigation bar and title in "A" reflect the content offset of the collection view. Scroll a couple lines, the large title turns small and centered on top. If I turn off large title, I still see the background color of the navigation bar change as it would if you were scrolling a view directly inside controller "A" without the container view.
Am I supposed to be manually capturing the gesture recognizer in B and somehow preventing the gesture to bubble up to A? It seems like strange behavior to have to correct. Any suggestions?
Thanks!
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
I've a QLPreviewController in the detail/secondary section of a UISplitViewController and when the user swipes down, it dismisses the entire split view.
Is there a way to prevent this?
Setting up UITabAccessory via setBottomAccessory(_:animated:) causing recursion internally on iPhone Air which is leading into a crash.
Sharing crash log & feedback below...
crashlog.crash
crash-feedback.json
I a using the current RC version of iOS on both my iPhone and iPad. I and developing an iCloud based app and it works correctly on iOS 18. When I upgraded to iOS 26 the iCloud functions work correctly but the push notifications do not work.
The issue appears to be creating subscriptions. The following code should create a subscription and does not get an error, but it did to create a subscription under iOS 26.
func subscribeToNotifications(recordType: String,
subscriptionID: String, notification: CKSubscription.NotificationInfo) {
let subscriptionIDForType = "\(subscriptionID)-\(recordType)"
let predicate = NSPredicate(value: true)
let subscription = CKQuerySubscription(recordType: recordType, predicate: predicate, subscriptionID: subscriptionIDForType, options: [.firesOnRecordCreation, .firesOnRecordUpdate, .firesOnRecordDeletion])
let notification = CKSubscription.NotificationInfo()
subscription.notificationInfo = notification
CKContainer.default().publicCloudDatabase.save(subscription) { (returnedSubscription, error) in
if let error = error {
print("Error saving subscription: \(error)")
} else {
print("Successfully saved subscription: recordType: " + recordType + " subscriptionID: " + subscriptionIDForType)
}
}
}
Print results:
Successfully saved subscription: recordType: folder subscriptionID: folderName-folder
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
Files and Storage
CloudKit
User Notifications
iPad and iOS apps on visionOS
Hi! I am learning Swift and UIKit for work. I am trying to automate using a pickerWheel in VisionOS, but since .adjust(toValue: ) was removed in VisionOS's API, I am absolutely struggling to find a way to set a pickerWheel to a specific value.
Currently, my solution is to calculate the amount of times I would need to increment/decrement the wheel to get from the current value to the desired value, then do so one at a time. However, this currently does not work, as .accessibilityIncrement() and .accessibilityDecrement() do not work, and .swipeUp() and .swipeDown() go too far. What can I do?
Note: I am not a frontend engineer, so while solutions may exist that involve changes to the frontend, I would much rather try and get the frontend we do have to work as is.
In our project, we are now using UIScene, and when click InputText to pull up Keyboard, and when rotate the device, the Keyboard does not update:
how can we fix this issue?
Hello,
this is very weird. I have an app where I use UIDocumentPickerViewController(forOpeningContentTypes: [.folder]) to let the users access to directories that are in the sandbox of other apps. It's been working since iOS 13.
On the beta versions of iOS and iPadOS 26.1 (betas 3 and 4), the second time the UIDocumentPickerViewController is presented, it becomes unresponsive, with a spinning wheel in the top right corner where the "Open" button should be.
I have absolutely no clue what the issue could be. It doesn't seem to be a widespread issue, but I have also no idea on how to find the origin and fix it.
As far as I can tell from the debugger, this line is executed:
DispatchQueue.main.async {
rootVC?.present(self.documentPicker, animated: true, completion: nil)
}
and then nothing else happens.
Topic:
UI Frameworks
SubTopic:
UIKit
Hi everyone,
I'm encountering an unexpected behavior with modal presentations in UIKit. Here’s what happens:
I have UIViewControllerA (let’s call it the "orange" VC) pushed onto a UINavigationController stack.
I present UIViewControllerB (the "red" VC, inside its own UINavigationController as a .formSheet) modally over UIViewControllerA.
After a short delay, I pop UIViewControllerA from the navigation stack.
Issue:
After popping UIViewControllerA, the modal UIViewControllerB remains visible on the screen and in memory. I expected that dismissing (popping) the presenting view controller would also dismiss the modal, but it stays.
Expected Behavior:
When UIViewControllerA (orange) is popped, I expect the modal UIViewControllerB (red) to be dismissed as well.
Actual Behavior:
The modal UIViewControllerB remains on screen and is not dismissed, even though its presenting view controller has been removed from the navigation stack.
Video example: https://youtube.com/shorts/sttbd6p_r_c
Question:
Is this the expected behavior? If so, what is the recommended way to ensure that the modal is dismissed when its presenting view controller is removed from the navigation stack?
Code snippet:
class MainVC: UIViewController {
private weak var orangeVC: UIViewController?
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .blue
let dq = DispatchQueue.main
dq.asyncAfter(deadline: .now() + 1) { [weak self] in
let vc1 = UIViewController()
vc1.view.backgroundColor = .orange
vc1.modalPresentationStyle = .overCurrentContext
self?.navigationController?.pushViewController(vc1, animated: true)
self?.orangeVC = vc1
dq.asyncAfter(deadline: .now() + 1) { [weak self] in
let vc2 = UIViewController()
vc2.view.backgroundColor = .red
vc2.modalPresentationStyle = .formSheet
vc2.isModalInPresentation = true
let nav = UINavigationController(rootViewController: vc2)
if let sheet = nav.sheetPresentationController {
sheet.detents = [.medium()]
}
self?.orangeVC?.present(nav, animated: true)
dq.asyncAfter(deadline: .now() + 1) { [weak self] in
self?.navigationController?.popViewController(animated: true)
}
}
}
}
}
Thank you for your help!
our app support silent push, and we use below code to get if app is launched by silent push:
if let remoteNotification = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],
let aps = remoteNotification["aps"] as? [AnyHashable: Any],
let contentAvailable = aps["content-available"] as? Int,
contentAvailable == 1 {
isSilentNotification = true
}
when app is launch and call:
application(_:didFinishLaunchingWithOptions:)
but when migrate to UIScene, the launchOptions is always nil, and we can not get to know if app is launched by silent push;
I read the develop doc:
it says:
If the app supports scenes, this is nil.
Continue using UIApplicationDelegate's application(_:didReceiveRemoteNotification:fetchCompletionHandler:) to process silent remote notifications after scene connection.
but the time for method calling
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
id too late.
So except in didReceiveRemoteNotification method calling:
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
are there any other ways to obtain the silent push flag when app is launch and has not didReceiveRemoteNotification call back.
Good day!
Have anyone experienced sudden crashes increase cause by CALayerInvalidGeometry · CALayer position contains NaN: [nan 5] that gets set via -[AVMobileGlassVolumeControlsView layoutSubviews]?
94% of crashes belong to iOS 26.0.1, while rest to 26.0. What's weird, though, is that it is caused by some AVKit internal logic and cant' understand how to track it down, neither how to reproduce.
Stack trace looks as follows:
0 CoreFoundation +0xc98c4 ___exceptionPreprocess
1 libobjc.A.dylib +0x317c0 _objc_exception_throw
2 CoreFoundation +0x1548d0 +[NSException raise:format:]
3 QuartzCore +0x909b4 CA::Layer::set_position(CA::Vec2<double> const&, bool)
4 QuartzCore +0x2af294 -[CALayer setPosition:]
5 UIKitCore +0xe9fc18 -[UIView _backing_setPosition:]
6 UIKitCore +0x18f6158 -[UIView setCenter:]
7 UIKitCore +0x1eb704 0x188b5e704 (0x188b5e5f4 + 272)
8 UIKitCore +0x1eb56c 0x188b5e56c (0x188b5e4f0 + 124)
9 UIKitCore +0x18fd318 -[UIView(Geometry) _resizeWithOldSuperviewSize:]
10 CoreFoundation +0x1514c ___NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
11 CoreFoundation +0xdd18c -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
12 UIKitCore +0x18fc6dc -[UIView(Geometry) resizeSubviewsWithOldSize:]
13 UIKitCore +0x18fabd0 -[UIView(Geometry) setFrame:]
14 AVKit +0x1b5a88 -[AVMobileGlassVolumeControlsView layoutSubviews]
15 UIKitCore +0x27074 0x18899a074 (0x188999d3c + 824)
16 UIKitCore +0x27b34 0x18899ab34 (0x18899ab14 + 32)
17 UIKitCore +0x190df64 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
18 QuartzCore +0xac9a4 CA::Layer::perform_update_(CA::Layer*, CALayer*, unsigned int, CA::Transaction*)
19 QuartzCore +0x8f2f8 CA::Layer::update_if_needed(CA::Transaction*, unsigned int, unsigned int)
20 UIKitCore +0x57b0 -[UIView(Hierarchy) layoutBelowIfNeeded]
21 AVKit +0x1b6634 ___74-[AVMobileGlassVolumeControlsView _updateVolumeFluidSliderEmphasizedScale]_block_invoke
22 UIKitCore +0x1b3e58 -[UIViewPropertyAnimator _runAnimations]
23 UIKitCore +0x19025f0 +[UIView(Animation) _performWithState:trackingIdentifier:duration:delay:animations:]
24 UIKitCore +0x83a650 ___49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke_4
25 UIKitCore +0x83a460 ___49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke
26 UIKitCore +0x83a210 -[UIViewPropertyAnimator startAnimationAsPaused:]
27 AVKit +0x1b6574 -[AVMobileGlassVolumeControlsView setEmphasized:]
28 AVKit +0x127510 ___64-[AVMobileGlassControlsViewController _animateVolumeEmphasisTo:]_block_invoke
29 UIKitCore +0x1b3e58 -[UIViewPropertyAnimator _runAnimations]
30 UIKitCore +0x83a590 ___49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke_3
31 UIKitCore +0x83a460 ___49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke
32 UIKitCore +0x83a514 ___49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke_2
33 UIKitCore +0x839e60 -[UIViewPropertyAnimator _setupAnimationTracking:]
34 UIKitCore +0x83a260 -[UIViewPropertyAnimator startAnimationAsPaused:]
35 AVKit +0x127480 -[AVMobileGlassControlsViewController _animateVolumeEmphasisTo:]
36 AVKit +0x12ea2c ___56-[AVMobileGlassControlsViewController _observationSetup]_block_invoke_5
37 AVKit +0xcbcd0 ___106-[AVObservationController startObservingNotificationForName:object:notificationCenter:observationHandler:]_block_invoke
38 CoreFoundation +0x519ec ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
39 CoreFoundation +0x51ab0 ____CFXRegistrationPost_block_invoke
40 CoreFoundation +0x5190c __CFXRegistrationPost
41 CoreFoundation +0x520ac __CFXNotificationPost
42 Foundation +0x94fc2c -[NSNotificationCenter postNotificationName:object:userInfo:]
43 AVKit +0x1b9bd8 -[AVSystemVolumeController _postNotificationForNameIfFullyInitialized:userInfo:]
44 AVKit +0x1b9dc0 -[AVSystemVolumeController setVolume:shouldShowHUD:]
45 AVKit +0x1b965c ___69-[AVSystemVolumeController _handleSystemVolumeDidChangeNotification:]_block_invoke
46 AVKit +0x1b8da4 -[AVSystemVolumeController _performOnMainThread:]
47 AVKit +0x1b95c0 -[AVSystemVolumeController _handleSystemVolumeDidChangeNotification:]
48 CoreFoundation +0x51a00 ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
49 CoreFoundation +0x51ab0 ____CFXRegistrationPost_block_invoke
50 CoreFoundation +0x5190c __CFXRegistrationPost
51 CoreFoundation +0x520ac __CFXNotificationPost
52 Foundation +0x94fc2c -[NSNotificationCenter postNotificationName:object:userInfo:]
53 MediaExperience +0x1039b0 ___76+[AVSystemControllerCommon postNotificationOnMainQueue:notification:object:]_block_invoke
54 MediaExperience +0x6b64 ___MXDispatchAsync_block_invoke
55 libdispatch.dylib +0x1ad8 __dispatch_call_block_and_release
56 libdispatch.dylib +0x1b7e8 __dispatch_client_callout
57 libdispatch.dylib +0x38b20 __dispatch_main_queue_drain.cold.5
58 libdispatch.dylib +0x10ec4 __dispatch_main_queue_drain
59 libdispatch.dylib +0x10e00 __dispatch_main_queue_callback_4CF
60 CoreFoundation +0x6b51c ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
61 CoreFoundation +0x1dd10 ___CFRunLoopRun
62 CoreFoundation +0x1cc40 __CFRunLoopRunSpecificWithOptions
63 GraphicsServices +0x1494 _GSEventRunModal
64 UIKitCore +0xa9dd8 -[UIApplication _run]
65 UIKitCore +0x4eb08 _UIApplicationMain
66 TuneIn Radio +0x1b318 main (main.m:28:22)
67 dyld +0x4e24 start
Hey all in iOS26.1 i seem to be getting a bunch of Constraint errors when setting the rightBarButtonItem leftBarButtonItem.
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x6000021a2a30 h=--& v=--& _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x13d84c080.width == 0 (active)>",
"<NSLayoutConstraint:0x6000021a1cc0 _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x13d84c080.leading == _UIButtonBarButton:0x106cd3ed0.leading (active)>",
"<NSLayoutConstraint:0x6000021a1d10 H:[_UIButtonBarButton:0x106cd3ed0]-(0)-| (active, names: '|':_TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x13d84c080 )>",
"<NSLayoutConstraint:0x6000021a19f0 'IB_Leading_Leading' H:|-(2)-[_UIModernBarButton:0x106cc80b0] (active, names: '|':_UIButtonBarButton:0x106cd3ed0 )>",
"<NSLayoutConstraint:0x6000021a1a40 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106cc80b0]-(2)-| (active, names: '|':_UIButtonBarButton:0x106cd3ed0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000021a1a40 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106cc80b0]-(2)-| (active, names: '|':_UIButtonBarButton:0x106cd3ed0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Curious if im setting something wrong, or maybe i can just ignore these (granted they are annoying in my logs) This wasnt happening in iOS 26.0
Topic:
UI Frameworks
SubTopic:
UIKit
We have received several cases that our app can not display uitableview cell in iOS26, but users said that they can select cells with single tab and the uitableview didselectcell delegate can response!
I have reported a feedback but no response. Does anyone have the same bugs with me?
You guys can see that the page is blank, I have a video a user sent to me can proved that he can select cell with gesture.
We cannot reproduce the bug and don't konw how to fixed, we think this is the bug with iOS26, so here for some help. This bug block our distribution of new version(support iOS26)
This is the feedback https://feedbackassistant.apple.com/feedback/20677046
We are using three column split view as root of our app and wants to hide the supplementary column alone in some cases and behaves like two column split view.
With the existing apis we are unable to achieve this since it hides primary column as well and not giving expected results.
.hide(.supplementary)
setViewController(nil, for: .supplementary)
But seen this behavior in Native Notes app when using the View as List and Gallery option.
is there any way to achieve this with maintaining three column split view itself ?
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 have a SwiftUI View containing a basic NavigationStack structure. I host this in a UIHostingController and display modally as a sheet in UIKit using UIViewController.present().
Problem: When I rotate my iOS device to landscape from portrait, the navigation bar's back button extends past the safe area into the left corner of the device. Then, rotating back to portrait the back button is pushed further towards the center - not matching the intended position. (see images below).
Is there an API call I am missing to handle this rotation case? Thanks!
Code Example
SwiftUI view - ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
Form {
NavigationLink {
Form {
Text("Hello")
}
.navigationTitle("Filter")
.navigationBarTitleDisplayMode(.inline)
} label: {
Text("Filter")
}
}
.navigationTitle("Filter")
.navigationBarTitleDisplayMode(.inline)
}
}
}
Main UIKit ViewController - ViewController.swift
import UIKit
import SwiftUI
class ViewController: UIViewController {
let swiftUIView = ContentView()
var hostingController: UIHostingController<ContentView>?
override func viewDidLoad() {
super.viewDidLoad()
hostingController = UIHostingController(rootView: swiftUIView)
guard let hostingController else { return }
hostingController.modalPresentationStyle = .formSheet
// Immediately present modally
DispatchQueue.main.async {
self.present(hostingController, animated: true)
}
}
}
More Detail
The issue only seems to appear for sheet modal presentation including these UIModalPresentationStyle:
.formSheet
.pageSheet
.popover
The issue does not appear in an app with SwiftUI app lifecycle or when using UIKit and adding the hosting controller as a child view controller. This specifically happens when presenting modally and when the view gets rendered as a sheet.
I tried various combinations of UIHostingController.sizingOptions and UIHostingController.safeAreaRegions, but never found something that fixed the issue.
To Build and Reproduce
Make a new Xcode project > iOS > App > Storyboard UI
Add file ContentView.swift with contents above.
Replace contents of existing file ViewController.swift with contents above.
Set minimum deployment target to iOS 18
Build and deploy to device running iOS 18.
Hold device in portrait.
Rotate device to landscape - observe back button extends past safe area.
Rotate device to portrait - observe back button is shifted too far towards the center.
Device & Builds Specs
iOS 18.6.2 - minimum deployment of 18.0
Devices Observed:
iPhone 12 Pro Max
iPhone 16 Pro Max
Xcode 26
Image Examples
I have a UITableView with multiple screens worth of cells and the height of the cells vary. At a certain point in the user's workflow, I want to prevent a specific cell from being scrolled out of view. I want it to allow it to scroll from the top of the screen to the bottom but not out of view.
I'm trying to solve this by updating the tableView.contentInset property with the following logic...
let visibleContentHeight = tableView.bounds.height
var insetTop = (cell.frame.origin.y - visibleContentHeight)
insetTop = (insetTop < 0) ? 0 : -insetTop
var insetBottom = tableView.contentSize.height - (cell.frame.origin.y + cell.frame.height + visibleContentHeight)
insetBottom = (insetBottom < 0) ? 0 : -insetBottom
tableView.contentInset = UIEdgeInsets(top: insetTop, left: 0, bottom: insetBottom, right: 0)
This doesn't seem to work exactly right. When scrolling, the cell's top/bottom doesn't line up with the view's top/bottom. And the difference between those margins is not consistent.
Printing out some the raw values, it looks like the cell's frame.origin sometimes changes as well as tableView.contentSize.height. I assume the system is using tableView.estimatedRowHeight to calculate the table's content height for the cells that are not loaded, so that's probably another factor.
Is setting contentInset not the way to do this? Is there another way? Is there an error in my math/logic? I must be missing something. Any help is appreciated.
Thanks.
Topic:
UI Frameworks
SubTopic:
UIKit
When I build my app via ios 26 sdk, I no longer see navigation titles on a split view controller. In the view hierarchy, I can still see it but its no longer rendering in the application itself. Any ideas?
Topic:
UI Frameworks
SubTopic:
UIKit
Hello! I've been using Objective-C to write a single-view application and have been using AppDelegate for my window setup.
However, with the next release of iOS, I need to adopt SceneDelegate into my app for it to work.
I'm having trouble getting my main ViewController to show up when the app starts. It just shows up as a black screen.
I built this app entirely programmatically. When I go into my info.plist file, I have everything but the Storyboard setup since, obviously, I don't have one.
I've left my code below.
Thank you!
My current AppDelegate:
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
#pragma mark - UISceneSession Configuration
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Create the configuration object
return [[UISceneConfiguration alloc] initWithName: @"Default" sessionRole: connectingSceneSession.role];
}
#pragma mark - Application Configuration
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
- (void) dealloc {
[super dealloc];
}
@end
My Current SceneDelegate:
#import "SceneDelegate.h"
#import "ViewController.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Ensure we have a UIWindowScene
if (![scene isKindOfClass:[UIWindowScene class]]) {
return;
}
UIWindowScene *windowScene = (UIWindowScene *)scene;
// Create and attach the window to the provided windowScene
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
// Set up the root view controller
ViewController *homeViewController = [[[ViewController alloc] init] autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController: homeViewController] autorelease];
// Present the window
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
}
@end
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
}
}
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.