發現應用在iTouch4上頁面左右滑動或push進一個視圖控制器時,非常的卡。最後發現時因為給導航控制器的邊框添加了陰影的原因。
之前的代碼:
- (void)addFrameLeftLine {
UIColor *color = [UIColor blackColor];
CGSize offset = CGSizeMake(0, 3);
float radius = 2;
float opacity = 1;
self.navigationController.view.layer.shadowColor = color.CGColor;
self.navigationController.view.layer.shadowOffset = offset;
self.navigationController.view.layer.shadowRadius = radius;
self.navigationController.view.layer.shadowOpacity = opacity;
}
修改後的代碼:
- (void)addFrameLeftLine {
CGPathRef shadow = CGPathCreateWithRect(CGRectInset(self.navigationController.view.bounds, -5, 0), NULL);
[self.navigationController.view.layer setShadowPath:shadow];
[self.navigationController.view.layer setShadowColor:[[UIColor blackColor] CGColor]];
[self.navigationController.view.layer setShadowOpacity:0.3];
[self.navigationController.view.layer setShadowRadius:2];
CFRelease(shadow);
}