发现应用在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);
}