由於某些原因,我試圖避免使用CAScrollLayer來做到這一點。我所追求的效果是逐步揭示(從底部到頂部)一個CALayer的內容(我之前加載過的一個PNG)。所以我想這樣做:我怎樣才能讓CAlayer的邊界動畫逐步顯示圖像?
layer.anchorPoint = CGPointMake(.5, 1);
CABasicAnimation* a = [CABasicAnimation animationWithKeyPath:@"bounds.size.height"];
a.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
a.fillMode = kCAFillModeBoth;
a.removedOnCompletion = NO;
a.duration = 1;
a.fromValue = [NSNumber numberWithFloat:0.];
a.toValue = [NSNumber numberWithFloat:layer.bounds.size.height];
[layer addAnimation:a forKey:nil];
這個問題是你可以告訴圖層的內容與邊界縮放。我試圖改變邊界,但內容始終保持原始大小,以便邊界能夠有效地剪切圖像,並隨着邊界的增加而變高。圖像「顯示」本身。
任何想法如何將其關閉或我可能會丟失什麼?
我知道,但因爲在一個以上的效率水平(可以有這些影響中的一小部分會立即發生,我需要自己處理CALayers)我決定不這樣做。現在我正在試驗contentRect,並且我能夠把它弄到幾乎正確。唯一的問題是內容rect動畫時,我也得到了一種在圖層內繪製的筆畫軌跡。 – SaldaVonSchwartz 2012-04-26 19:21:08
contentRect的文檔說「如果請求單位矩形外的像素,內容圖像的邊緣像素將向外擴展」所以我想這就是爲什麼我得到筆畫效果 – SaldaVonSchwartz 2012-04-26 19:30:29