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

WidgetKit: add new widget to bundle
Hi, I have an existing Mac app on the App Store with a couple of widgets as part of the app. I want to now add a new widget to the WidgetBundle. When I build the updated app with Xcode, and then run the updated app, the widgets list doesn't seem to get updated in Notification Center or in the WidgetKit Simulator. I do have the App Store version installed in the /Applications folder as well, so there might be some conflict. What's the trick to getting the widgets list to run the debug version?
0
0
99
Mar ’25
Random PDFKit crash on text selection
At this line of code (SketchTextSelectionManager.swift:378), sometimes there will be crashes based on crashlytics reports. In the reports, it seems like this only happens for RTL text range. let selection = pdfPage.selection( from: CGPoint(x: fromStart.x + 1, y: fromStart.y - 1), to: CGPoint(x: toEnd.x - 1, y: toEnd.y + 1) ) This is directly calling into PDFKit's PDFPage#selection method: https://developer.apple.com/documentation/pdfkit/pdfpage/selection(from:to:) Attached the full stacktrace: Crashed: com.apple.root.user-initiated-qos.cooperative 0 CoreGraphics 0x30598c PageLayout::convertRTLTextRangeIndexToStringRangeIndex(long) const + 156 1 CoreGraphics 0x44c3f0 CGPDFSelectionCreateBetweenPointsWithOptions + 224 2 PDFKit 0x91d00 -[PDFPage selectionFromPoint:toPoint:type:] + 168 3 MyApp 0x841044 closure #1 in SketchTextSelectionManager.handleUserTouchMoved(_:) + 378 (SketchTextSelectionManager.swift:378) 4 MyApp 0x840cb0 SketchTextSelectionManager.handleUserTouchMoved(_:) + 205 (CurrentNoteManager.swift:205) 5 libswift_Concurrency.dylib 0x60f5c swift::runJobInEstablishedExecutorContext(swift::Job*) + 252 6 libswift_Concurrency.dylib 0x63a28 (anonymous namespace)::ProcessOutOfLineJob::process(swift::Job*) + 480 7 libswift_Concurrency.dylib 0x6101c swift::runJobInEstablishedExecutorContext(swift::Job*) + 444 8 libswift_Concurrency.dylib 0x62514 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 144 9 libdispatch.dylib 0x15ec0 _dispatch_root_queue_drain + 392 10 libdispatch.dylib 0x166c4 _dispatch_worker_thread2 + 156 11 libsystem_pthread.dylib 0x3644 _pthread_wqthread + 228 12 libsystem_pthread.dylib 0x1474 start_wqthread + 8
0
1
303
Feb ’25
Debugging Snapshot Thread Confinement Warning in UITableViewDiffableDataSource
I first applied a snapshot on the main thread like this: var snapshot = NSDiffableDataSourceSnapshot<Section, MessageViewModel>() snapshot.appendSections([.main]) snapshot.appendItems([], toSection: .main) dataSource.applySnapshotUsingReloadData(snapshot) After loading data, I applied the snapshot again using: Task { @MainActor in await dataSource.applySnapshotUsingReloadData(snapshot) } On an iPhone 13 mini, I received the following warning: Warning: applying updates in a non-thread confined manner is dangerous and can lead to deadlocks. Please always submit updates either always on the main queue or always off the main queue However, this warning did not appear when I ran the same code on an iPhone 16 Pro simulator. Can anyone explain it to me? Thank you
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
98
May ’25
Best Way to Help Users Diagnose iOS App Crashes with No UI Feedback
Hi all, We're working on an iOS application and would like to improve our ability to diagnose failures - especially in scenarios where the app crashes before it can present any UI to the user. A few specific questions: In case of an exception or crash, is there a way to log the issue so the user (or our support team) can understand the cause of the failure? If the app crashes abruptly (e.g., due to a runtime exception or crash during launch), is there a recommended way to persist error information before the process terminates? Are there Apple-supported mechanisms (like crash reporting tools or APIs) we can integrate that would help us capture such issues? What’s the best practice for enabling support teams to assist users based on crash reports - especially for crashes that happen before any user interaction? Our goal is to make sure users aren't left in the dark if the app fails to start, and to allow us to deliver timely updates or support based on the cause of the crash. Thanks in advance for your guidance!
Topic: UI Frameworks SubTopic: General Tags:
0
0
104
May ’25
FamilyActivityTitleView Label has wrong text color when app is using different than system theme
Hello, In a new app I am working on I noticed the FamilyActivityTitleView that displays "ApplicationToken" has wrong (black) color when phone is set to light mode but app is using dark mode via override. We display user's selected apps and the labels are rendered correctly at first, but then when user updates selection with FamilyActivityPicker, then those newly added apps are rendered with black titles. The problem goes away when I close the screen and open it again. It also doesn't happen when phone is set to dark theme. I am currently noticing the issue on iOS 18.4.1. I have tried various workarounds like forcing white text in the custom label style, forcing re-render with custom .id value but nothing helped. Is there any way how to fix this?
0
0
127
May ’25
NSDocumentController subclass with remembered document options
Hi all, I am trying to allow users of my app to select extra options when opening documents, and to remember those options when re-opening documents at launch. So far best idea I have is: Subclass NSDocumentController to provide an NSOpenPanel.accessoryView with the options Create a URL bookmark for each opened file and keep a mapping of bookmarks to options On launch and when the recent documents list changes, prune the stored mappings to match only the recent items Has anyone done this before, or know of a better approach? Thank you.
Topic: UI Frameworks SubTopic: AppKit
0
0
326
Feb ’25
UI not updating during render
I've coded a small raytracer that renders a scene (based on Peter Shirley's tutorial, I just coded it in Swift). The raytracer itself works fine, outputs a PPM file which is correct. However, I was hoping to enclose this in a UI that will update the picture as each pixel value gets updated during the render. So to that end I made a MacOS app, with a basic model-view architecture. Here is my model: // // RGBViewModel.swift // rtweekend_gui // // import SwiftUI // RGB structure to hold color values struct RGB { var r: UInt8 var g: UInt8 var b: UInt8 } // ViewModel to handle the RGB array and updates class RGBViewModel: ObservableObject { // Define the dimensions of your 2D array let width = 1200 let height = 675 // Published property to trigger UI updates @Published var rgbArray: [[RGB]] init() { // Initialize with black pixels rgbArray = Array(repeating: Array(repeating: RGB(r: 0, g: 0, b: 0), count: width), count: height) } func render_scene() { for j in 0..&lt;height { for i in 0..&lt;width { // Generate a random color let r = UInt8.random(in: 0...255) let g = UInt8.random(in: 0...255) let b = UInt8.random(in: 0...255) // Update on the main thread since this affects the UI DispatchQueue.main.async { // Update the array self.rgbArray[j][i] = RGB(r: r, g: g, b: b) } } } } and here is my view: // // RGBArrayView.swift // rtweekend_gui // // import SwiftUI struct RGBArrayView: View { // The 2D array of RGB values @StateObject private var viewModel = RGBViewModel() // Control the size of each pixel private let pixelSize: CGFloat = 1 var body: some View { VStack { // Display the RGB array Canvas { context, size in for y in 0..&lt;viewModel.rgbArray.count { for x in 0..&lt;viewModel.rgbArray[y].count { let rgb = viewModel.rgbArray[y][x] let rect = CGRect( x: CGFloat(x) * pixelSize, y: CGFloat(y) * pixelSize, width: pixelSize, height: pixelSize ) context.fill( Path(rect), with: .color(Color( red: Double(rgb.r) / 255.0, green: Double(rgb.g) / 255.0, blue: Double(rgb.b) / 255.0 )) ) } } } .border(Color.gray) // Button to start filling the array Button("Render") { viewModel.render_scene() } .padding() } .padding() .frame(width: CGFloat(viewModel.width) * pixelSize + 40, height: CGFloat(viewModel.height) * pixelSize + 80) } } // Preview for SwiftUI struct RGBArrayView_Previews: PreviewProvider { static var previews: some View { RGBArrayView() } } The render does work and the image displays, however, I thought I set it up to show the image updating pixel by pixel and that doesn't happen, the image shows up all at once. What am I doing wrong?
0
0
97
May ’25
AppEntity with @Parameter Options Works in Shortcuts App but Not with Siri
I’m working with AppIntents and AppEntity to integrate my app’s data model into Shortcuts and Siri. In the example below, I define a custom FoodEntity and use it as a @Parameter in an AppIntent. I’m providing dynamic options for this parameter via an optionsProvider. In the Shortcuts app, everything works as expected: when the user runs the shortcut, they get a list of food options (from the dynamic provider) to select from. However, in Siri, the experience is different. Instead of showing the list of options, Siri asks the user to say the name of the food, and then tries to match it using EntityStringQuery. I originally assumed this might be a design decision to allow hands-free use with voice, but I found that if you use an AppEnum instead, Siri does present a tappable list of options. So now I’m wondering: why the difference? Is there a way to get the @Parameter with AppEntity + optionsProvider to show a tappable list in Siri like it does in Shortcuts or with an AppEnum? Any clarification on how EntityQuery.suggestedEntities() and DynamicOptionsProvider interact with Siri would be appreciated! struct CaloriesShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: AddCaloriesInteractive(), phrases: [ "Add to \(.applicationName)" ], shortTitle: "Calories", systemImageName: "fork" ) } } struct AddCaloriesInteractive: AppIntent { static var title: LocalizedStringResource = "Add to calories log" static var description = IntentDescription("Add Calories using Shortcuts.") static var openAppWhenRun: Bool = false static var parameterSummary: some ParameterSummary { Summary("Calorie Entry SUMMARY") } var displayRepresentation: DisplayRepresentation { DisplayRepresentation(stringLiteral:"Add to calorie log") } @Dependency private var persistenceManager: PersistenceManager @Parameter(title: LocalizedStringResource("Food"), optionsProvider: FoodEntityOptions()) var foodEntity: FoodEntity @MainActor func perform() async throws -> some IntentResult & ProvidesDialog { return .result(dialog: .init("Added \(foodEntity.name) to calorie log")) } } struct FoodEntity: AppEntity { static var defaultQuery = FoodEntityQuery() @Property var name: String @Property var calories: Int init(name: String, calories: Int) { self.name = name self.calories = calories } static var typeDisplayRepresentation: TypeDisplayRepresentation { TypeDisplayRepresentation(name: "Calorie Entry") } static var typeDisplayName: LocalizedStringResource = "Calorie Entry" var displayRepresentation: AppIntents.DisplayRepresentation { DisplayRepresentation(title: .init(stringLiteral: name), subtitle: "\(calories)") } var id: String { return name } } struct FoodEntityQuery: EntityQuery { func entities(for identifiers: [FoodEntity.ID]) async throws -> [FoodEntity] { var result = [FoodEntity]() for identifier in identifiers { if let entity = FoodDatabase.allEntities().first(where: { $0.id == identifier }) { result.append(entity) } } return result } func suggestedEntities() async throws -> [FoodEntity] { return FoodDatabase.allEntities() } } extension FoodEntityQuery: EntityStringQuery { func entities(matching string: String) async throws -> [FoodEntity] { return FoodDatabase.allEntities().filter({$0.name.localizedCaseInsensitiveCompare(string) == .orderedSame}) } } struct FoodEntityOptions: DynamicOptionsProvider { func results() async throws -> ItemCollection<FoodEntity> { ItemCollection { ItemSection("Section 1") { for entry in FoodDatabase.allEntities() { entry } } } } } struct FoodDatabase { // Fake data static func allEntities() -> [FoodEntity] { [ FoodEntity(name: "Orange", calories: 2), FoodEntity(name: "Banana", calories: 2) ] } }
0
1
96
May ’25
Unexpected UINavigationBar Behavior During View Transitions in iOS 18
In iOS 18, I've observed unexpected behavior related to the UINavigationBar when transitioning between view controllers that have differing navigation bar visibility settings. Specifically, when returning from a modal presentation or a web view, the navigation bar reappears with an unexpected height (e.g., 103 points) and lacks content, displaying only an empty bar. Start with a UIViewController (e.g., HomeViewController) where the navigation bar is hidden using: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.setNavigationBarHidden(true, animated: animated) } Present another UIViewController (e.g., a web view) modally. Dismiss the presented view controller. Observe that upon returning to HomeViewController, the navigation bar is visible with increased height and lacks expected content. Expected Behavior: The navigation bar should remain hidden upon returning to HomeViewController, maintaining the state it had prior to presenting the modal view controller. Actual Behavior: Upon dismissing the modal view controller, the navigation bar becomes visible with an unexpected height and lacks content, leading to a disrupted user interface. Additional Observations: This issue is specific to iOS 18; it does not occur in iOS 17 or earlier versions. The problem seems to stem from setting the navigation bar to be visible in the viewWillDisappear method, as shown below: override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.setNavigationBarHidden(false, animated: animated) } Removing or modifying this line mitigates the issue, suggesting a change in the view controller lifecycle behavior in iOS 18. Request for Clarification: Is this change in behavior intentional in iOS 18, or is it a regression? Understanding whether this is a new standard or a bug will help in implementing appropriate solutions. Workaround: As a temporary measure, I've adjusted the navigation bar visibility settings to avoid changing its state in viewWillDisappear, instead managing it in viewWillAppear or viewDidAppear. References: Similar issues have been discussed in the Apple Developer Forums: iPad OS 18 UINavigationBar display incorrectly
Topic: UI Frameworks SubTopic: UIKit
0
0
109
May ’25
Crash on removal of QLPreviewController and _EXRemoteViewController
I have a controller that displays a pdf using UIDocumentInteractionController as the presented view. When users open it up, it shows fine. User gets the app backgrounded and session timed out. After timed out, when the app is brought to foreground, I bring our loginVC by removing the old VC used to show the UIDocumentInteractionController. All the crashes are happening at this point. I am not able to reproduce it, but our alert systems show we have crashes happening. The code that shows the pdf is straight forward documentViewController = UIDocumentInteractionController() documentViewController?.delegate = self documentViewController?.url = url documentViewController?.presentPreview(animated: true) and we reset it to nil in delegate documentInteractionControllerDidEndPreview Based on the crash trace, it seems like the crash happens when our login VC replaces it and only when pdf was displayed. The reason of stressing ONLY because when we have other viewcontroller present and they are removed in a similar way, we do not see any issue. So we always replace first and then add a new one childViewController.willMove(toParent: nil) childViewController.viewIfLoaded?.removeFromSuperview() childViewController.removeFromParent() addChild(childViewController) view.addSubview(childViewController.view) childViewController.view.frame = view.bounds childViewController.didMove(toParent: self) Raised a ticket with Apple, but I haven't heard back, and it's been a month. Posting here in case anyone experiences the same and has any solutions. I saw some related posts, and solution was to remove the pdf the moment the app goes to the background, but I am trying to find some alternate solution if possible.
Topic: UI Frameworks SubTopic: UIKit
0
0
218
Mar ’25
Open file directly into editor view with DocumentGroup
This was also raised in FB17028569 I have iOS document based app using DocumentGroup. I can create and save documents as expected. All that functionality is fine. @main struct FooBarApp: App { var body: some Scene { DocumentGroup(newDocument: { FoobarDocument() }) { config in MainView(document: config.document) } The problem is when I open an app document from Files.app or Messages the document is never opened directly into the editor, the document browser interface is always presented and the user must manually select the document to open an editor. This also happens when I use UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil) to open a new scene. The doc isn't opened into my editor. I believe my plist document types are setup correctly and that my ReferenceFileDocument is setup correctly <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>foobar</string> </array> <key>CFBundleTypeIconFile</key> <string>icon-128</string> <key>CFBundleTypeIconSystemGenerated</key> <integer>1</integer> <key>CFBundleTypeMIMETypes</key> <array> <string>application/json</string> </array> <key>CFBundleTypeName</key> <string>Foobar Project</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.digital-dirtbag.foobar</string> </array> <key>NSUbiquitousDocumentUserActivityType</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).ubiquitousdoc</string> </dict> </array> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Foobar Project</string> <key>UTTypeIconFiles</key> <array> <string>icon-128.png</string> </array> <key>UTTypeIdentifier</key> <string>com.digital-dirtbag.foobar</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>foobar</string> </array> </dict> </dict> The question is does DocumentGroup on iOS even support opening documents directly into the editor view? I know it works on macOS as expected as I tried this with the demo code and it exhibits the same symptoms. Opening a document from iOS Files.app only gets you as far as the document browser while macOS will open an editor directly.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
71
May ’25
Bundling OSX installer plugin with productbuild/pkgbuild
I'm trying to create a .pkg installer with productbuild/pkgbuild. But I'd also like to add my custom installer plugin to this. I'm using the following script. I'd like to add my bundle into this script. Since there are no official docs from apple how to do this nor there are a lot of updated resources, here are some things I have tried. adding the following line to Distrubtion.xml <bundle id="pluginid" path="path/to/myplugin.bundle"/> adding component tag to pkgbuild also doesn't do anything --component "path/to/myplugin.bundle" The bundle itself is build with XCode - it is a simple UI for user to type some input in Apple provides documentation for Distribution.xml file, which supports different UI elements but doesn't support text input - docs I have been also looking at this tutorial , it is very outdated but i could still fit it to my needs except the part where the .bundle file needs to be inserted into .pkg. Note - there is no option to view the contents of .pkg file build with pkbuild/productbuild How can i do this process correctly? I would like to link my installer pane plugin to a generic .pkg(with licenses and so on). I'd appreciate any kind of help!
0
0
109
May ’25
How to return a UIMenu for read-only UITextView
I have a UITextView being added at runtime to a UIImageView as the result of doing text recognition. It's set to be editable = NO and selectable = YES. When I set the text and select it, it asks the delegate for the menu to display via: textView:editMenuForTextInRange:suggestedActions: The suggested items contains many UIAction and UICommand objects that have private methods or do not have the destructive attribute set, yet they are destructive. Some of these are: promptForReplace: transliterateChinese: _insertDrawing: _showTextFormattingOptions: I need to return a menu that has only non-destructive commands in it. First, why isn't UITextView sending only non-destructive suggested commands when its editable is NO? Second, how can I filter the array of suggested commands when it's impossible to know if they're destructive (as some are missing that attribute)? In addition to that, even non-destructive commands are causing an unrecognized selector exception, such as the Speak command, which it is sending to my view controller instead of to the UITextView, which is the only thing that knows what the text is that it should speak.
Topic: UI Frameworks SubTopic: UIKit
0
0
216
Feb ’25
CPTabBarTemplate in CarPlay Simulator: Tab Becomes Inactive on Re-selection
I am facing an issue in my CarPlay app using CPTabBarTemplate. The app has two tabs, and on launch, the first tab is correctly selected. However, when I tap on the first tab again, instead of staying active, it becomes inactive. This behavior is unexpected, as re-selecting the active tab should typically maintain its selected state. Has anyone else encountered this issue or found a workaround to prevent the tab from becoming inactive?
0
0
58
May ’25
high internal cpu usage
Hi, I am developing a new SwiftUI app. Running under OSX, I see very high cpu usage (I am generating lots of gpu based updates which shouldn't affect the cpu). I have used the profiler to ensure my swift property updates are minimal, yet the cpu usage is high coming from SwiftUI. It seems the high cpu usage is coming from NSAppearance, specifically, CUICopyMeasurements - for a single button??? But the swift updates don't show any buttons being updating
Topic: UI Frameworks SubTopic: SwiftUI
0
0
277
Feb ’25
iOS UILabel textAlignment .justified results in wrong rect by layoutManager.boundingRect
I have a UILabel subclass showing NSAttributedString in which I need to draw a rounded rectangle background color around links: import UIKit class MyLabel: UILabel { private var linkRects = [[CGRect]]() private let layoutManager = NSLayoutManager() private let textContainer = NSTextContainer(size: .zero) private let textStorage = NSTextStorage() override func draw(_ rect: CGRect) { let path = UIBezierPath() linkRects.forEach { rects in rects.forEach { linkPieceRect in path.append(UIBezierPath(roundedRect: linkPieceRect, cornerRadius: 2)) } } UIColor.systemGreen.withAlphaComponent(0.4).setFill() path.fill() super.draw(rect) } override init(frame: CGRect) { super.init(frame: frame) setup() } required init?(coder: NSCoder) { super.init(coder: coder) setup() } private func setup() { numberOfLines = 0 adjustsFontForContentSizeCategory = true isUserInteractionEnabled = true lineBreakMode = .byWordWrapping contentMode = .redraw clearsContextBeforeDrawing = true isMultipleTouchEnabled = false backgroundColor = .red.withAlphaComponent(0.1) textContainer.lineFragmentPadding = 0 textContainer.maximumNumberOfLines = numberOfLines textContainer.lineBreakMode = lineBreakMode textContainer.layoutManager = layoutManager layoutManager.textStorage = textStorage layoutManager.addTextContainer(textContainer) textStorage.addLayoutManager(layoutManager) } override func layoutSubviews() { super.layoutSubviews() calculateRects() } private func calculateRects(){ linkRects.removeAll() guard let attributedString = attributedText else { return } textStorage.setAttributedString(attributedString) let labelSize = frame.size textContainer.size = labelSize layoutManager.ensureLayout(for: textContainer) let textBoundingBox = layoutManager.usedRect(for: textContainer) print("labelSize: \(labelSize)") print("textBoundingBox: \(textBoundingBox)") var wholeLineRanges = [NSRange]() layoutManager.enumerateLineFragments(forGlyphRange: NSRange(0 ..< layoutManager.numberOfGlyphs)) { _, rect, _, range, _ in wholeLineRanges.append(range) print("Whole line: \(rect), \(range)") } attributedString.enumerateAttribute(.link, in: NSRange(location: 0, length: attributedString.length)) { value, clickableRange, _ in if value != nil { var rectsForCurrentLink = [CGRect]() wholeLineRanges.forEach { wholeLineRange in if let linkPartIntersection = wholeLineRange.intersection(clickableRange) { var rectForLinkPart = layoutManager.boundingRect(forGlyphRange: linkPartIntersection, in: textContainer) rectForLinkPart.origin.y = rectForLinkPart.origin.y + (textContainer.size.height - textBoundingBox.height) / 2 // Adjust for vertical alignment rectsForCurrentLink.append(rectForLinkPart) print("Link rect: \(rectForLinkPart), \(linkPartIntersection)") } } if !rectsForCurrentLink.isEmpty { linkRects.append(rectsForCurrentLink) } } } print("linkRects: \(linkRects)") setNeedsDisplay() } } And I use this as such: let label = MyLabel() label.setContentHuggingPriority(.required, for: .vertical) label.setContentHuggingPriority(.required, for: .horizontal) view.addSubview(label) label.snp.makeConstraints { make in make.width.lessThanOrEqualTo(view.safeAreaLayoutGuide.snp.width).priority(.required) make.horizontalEdges.greaterThanOrEqualTo(view.safeAreaLayoutGuide).priority(.required) make.center.equalTo(view.safeAreaLayoutGuide).priority(.required) } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .justified let s = NSMutableAttributedString(string: "Lorem Ipsum: ", attributes: [.font: UIFont.systemFont(ofSize: 17, weight: .regular), .paragraphStyle: paragraphStyle]) s.append(NSAttributedString(string: "This property controls the maximum number of lines to use in order to fit the label's text into its bounding rectangle.", attributes: [.link: URL(string: "https://news.ycombinator.com/") as Any, .foregroundColor: UIColor.link, .font: UIFont.systemFont(ofSize: 14, weight: .regular), .paragraphStyle: paragraphStyle])) label.attributedText = s Notice the paragraphStyle.alignment = .justified This results in: As you can see, the green rect background is starting a bit further to the right and also ending much further to the right. If I set the alignment to be .left or .center, then it gives me the correct rects: Also note that if I keep .justified but change the font size for the "Lorem Ipsom:" part to be a bit different, lets say 16 instead of 17, then it gives me the correct rect too: Also note that if we remove some word from the string, then also it starts giving correct rect. It seems like if the first line is too squished, then it reports wrong rects. Why is .justified text alignment giving me wrong rects? How can I fix it?
Topic: UI Frameworks SubTopic: UIKit
0
0
93
May ’25