CALayer backed anchorPoint property is not .5, .5 by default?

Discussion in 'Mac Programming' started by Duncan C, Jun 7, 2013.

  1. macrumors 6502a

    Duncan C

    #1
    I've been doing iOS long enough now that my Mac OS is rusty. Sad but true.

    I'm back doing some Mac development, and animation is a lot harder.

    There's no view-based animation like there is in iOS, and I miss it. For quick-and dirty animation, the UIView animateWithDuration:animations: block-based animation calls are hard to beat.

    So, drop back and punt. I've set "needsLayer" to true for several NSView objects.

    Then I try to create a CABasicAnimation to grow my view from small to large.

    Just like in iOS, the docs say that the center of a layer is it's anchorPoint, which defaults to .5, .5 (the center of the layer.) However, when I create a transform animation that animates my view's backing layer from a point (scale to .001, .001, 1) up to the identity matrix, it grows from the lower left corner (0,0) instead.

    I have to set the anchorPoint to .5,.5 manually, and then I have to shift the position of the layer to half-width, half-height to compensate.

    What am I missing?
     

Share This Page