iOS CGPath提升阴影性能
发现应用在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);
}
上一篇: asp下实现IP限制函数代码
下一篇: 应用SVM对MNIST数据集进行分类