2012-04-17 24 views
0

這不是引用任何特定的代碼,但我注意到,當我有一個UIView將陰影添加到它的圖層時,在界面方向之間旋轉時的動畫變爲更滯後/波濤洶涌。當陰影可見時,iOS屏幕旋轉會退化

有沒有人注意到這個問題或找到解決方法?

回答

1

有些東西在CPU時間方面非常昂貴。在樂器中查看一段時間。

  • 陰影
  • 貝塞爾路徑與破折號(真貴)
  • 貝塞爾路徑

那不是一個完整列表。我懷疑漸變也會在那裏。

如果您發現這些東西正在降級您的動畫或重繪,您需要在UIViewController方法中切換它們。

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
//disable shadows + expensive drawing 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
//enable shadows + expensive drawing 
} 
+0

非常感謝好先生。儘管如此,它們實際上降低了性能,實在太糟糕了。也許在視圖下方顯示預先製作的陰影UIImage,而不是使用內置陰影渲染。 – 2012-04-20 04:04:24

2

當使用陰影的CALayershadowPath特性使得在性能上非常(!)noticable差異,尤其是在新的iPad。雖然我同意在更改顯示屏方向時禁用陰影是個不錯的主意,但也可以嘗試僅使用shadowPath(如果您尚未使用它)。雖然路徑可以是任何有效的CGPathRef,但在大多數情況下,這是你想要的:

self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.layer.bounds].CGPath;