NSView VisibleRect Behavior in Different macOS Versions

I am use XCode 15.2 and macOS SDK 14.2.

I placed an NSView inside the NSClipView of an NSScrollView, the NSView is smaller than the NSClipView, always centered.

On Ventura, regardless of whether clipsToBounds is set, the bounds and visibleRect of the NSView are the same.

However, on Sonoma, even after overriding -(BOOL)clipsToBounds { return YES; }, the bounds is correct, but the visibleRect (the red rect) is still the same size as the NSClipView, results in the text is not clipped.

Am I missing something or doing something wrong? How can I make the visibleRect of the NSView consistent with its bounds?

@arthur_z Could you please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project

@DTS Engineer Sure, here it is https://zippyshare.day/STMcNotUvKjprAY/file

Not quite sure if the previous link is available, if not, please use this one:

https://drive.google.com/file/d/1bP-XU2sVJFtBQ9pg7U5xhFaeaoQfoX01/view?usp=drive_link

NSView VisibleRect Behavior in Different macOS Versions
 
 
Q