Re: Animating view transitions with Core Animation (problems with BasicCocoaAnimations sample)
Re: Animating view transitions with Core Animation (problems with BasicCocoaAnimations sample)
- Subject: Re: Animating view transitions with Core Animation (problems with BasicCocoaAnimations sample)
- From: "Ken Ferry" <email@hidden>
- Date: Tue, 14 Oct 2008 20:53:28 -0700
On Mon, Oct 13, 2008 at 3:51 PM, Jim Correia <email@hidden> wrote:
> - Animation for -replaceSubview:with: appears to require a layer backed view tree.
This is true. Also true of animations for hiding or adding or removing views.
> - Focus rings are drawn incorrectly for editable NSTextField and
> friends [2]
When a view draws a focus ring, it just draws it as part of its normal
drawRect: drawing. When the drawing is being targeted into a layer,
that means that the focus ring cannot extend outside of the layer.
The general approach to a workaround would be to make sure that the
view is padded out from where the text field cell is drawn, providing
enough space in the layer for the focus ring to draw in.
> - Non-editable NSTextFields have incorrect anti-aliasing (without
> Scott Stevenson's hack)
I'm not aware of Scott's hack, but the problem is that the algorithm
for LCD text smoothing requires knowledge of the pixel colors behind
the text at draw time. You'll see the same degradation whenever text
is drawn into a transparent buffer. Windows are usually opaque, but
in the case of layers, each view is its own buffer.
The simplest fix is to check the drawsBackground checkbox on the field
in IB, and then select the windowBackgroundColor from the Developer
palette in the color panel. (Any opaque color will do, but in most
cases you'd want to match the window.) More complicated than but more
flexible is to override drawRect: and draw something opaque before
calling super. If none of this is applicable, you do better to turn
off text smoothing entirely in a drawRect: override, using
CGContextSetShouldSmoothFonts. At some point in the future
NSTextField may itself turn off text smoothing before drawing if layer
backed mode is on and the field does not think it's going to opaquely
fill the buffer behind the text.
> Problem #3:
>
> In order to arrange for my view tree to only be layer backed for the
> duration of the animation, I need to know when the animation finishes :-)
>
> The benefit of the implicit view animations is that much of the heavy
> lifting has already been done for me, so I'd like to take advantage of it if
> possible. The problem, though, is that since I'm not running the animations
> explicitly, I don't know when they are done.
>
> My current hack is to begin the implicit animations in a group, and use a
> perform delayed action to cleanup after the animation (based on the groups
> interval.)
>
> This feels like a hack though. Is there a better way?
I think that's the recommended approach.
-Ken
Cocoa Frameworks
_______________________________________________
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