NSView draws unwanted "seams" for certain zoom factors
NSView draws unwanted "seams" for certain zoom factors
- Subject: NSView draws unwanted "seams" for certain zoom factors
- From: Martin Wierschin via Cocoa-dev <email@hidden>
- Date: Thu, 8 Oct 2020 14:52:13 -0700
I have a large custom NSView subclass that's set as an NSScrollView's
documentView. This view achieves zooming in the standard AppKit way, by having
a zoom factor between the frame and bounds sizes, eg: frame.size.width =
bounds.size.width * 2.0. This has worked just fine for years.
The problem is that on modern versions of macOS, for certain zoom factors,
there are "seams" that show up during drawing. The seams are fine lines that
show some view's background color (or stale content from a prior drawing pass).
The seams are always aligned in neat rectangular patterns, which tipped me off
that macOS is doing some kind of tiling.
After poking around I see that my view is assigned a CALayer, despite never
opting-in via setWantsLayer or anything like that. This implicit layer backing
seems to be expected on current versions of macOS, but it's definitely the
cause of my problem. I can see that my view is assigned a layer like:
_NSViewBackingLayer → sublayers: _NSTiledLayer
If I increase the tileSize property of this automatically generated layer (eg:
from 512x512 to 2048x2048), I can decrease the visual frequency of the problem.
But this is naturally a hack, and not a complete solution. The seams still
occur, just less often.
Can I somehow opt my view out of implicit layer backing? Is there a modern way
to implement zoom now that everything is using layers? Thanks for any help!
~Martin Wierschin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden