By "some text that should appear the same," did you mean that the text size (both width and height) changes proportionally with the window size?
Correct.
Worth mentioning though, adjustsFontSizeToFitWidth doesn't provide a pixel perfection result.
I haven't used UILabel.adjustsFontSizeToFitWidth before, so I'm not sure how it actually behaves, and I'm also not sure what you mean with "pixel perfection".
I'm looking for a solution that resizes the text so that it stays proportional to the container view frame (which has a fixed aspect ratio). To be specific, I'm simulating subtitles on top of a video.
While playing with NSString.size(withAttributes:) and NSAttributedString.size(), I noticed that these methods only allow me to determine the size of a string when laid out on a single, infinite line. There is no equivalent to NSString.draw(in:withAttributes:) that also takes a rectangle. Should I instead use NSTextView (in which the text is eventually laid out anyway) and query its frame property?
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: