I have a CALayer with a CATextLayer sublayer. When I apply a transform or otherwise resize the CALayer, I need the CATextLayer to resize within its parent's bounds. Upon resize, the CATextLayer also needs to truncate its characters without distorting the proportion of the characters. This effect can be seen in Garageband for iPad when you resize a clip in the sequence view (screen below).
In my attempt to resize the CATextLayer within it's parent layer's bounds, I have:
- set the truncationMode property of my CATextLayer to kCATruncationMiddle.
- set the masksToBounds property of my CALayer
- set a default frame rectangle for CATextLayer (otherwise it doesn't draw)
Here's what happens:
- When I apply an animated transformation to the parent layer (via touch event), the CATextLayer characters stretch and distort.
- When the animated transformation ends, the parent layer is redrawn. The CATextLayer does not appear outside of the parent layer, but its frame rect remains at what I initiall开发者_如何学编程y set it to.
What it sounds like you want to do is animate both the CALayer
's and CATextLayer
's bounds
property, not their transform
property.
精彩评论