iOS:创建一个侧面的阴影 [英] iOS: Create one sideded dropshadow
问题描述
我有以下模仿脸谱的菜单样式布局。我想在左侧有一个像下面的阴影,但是我使用层阴影的代码使应用程序LAGGY。我找不到一个好的替代解决方案。有没有人可以选择创建一个不影响应用程序性能的drophadow?
I have the below menu style layout that mimics facebook. I would like to have a dropshadow on the left side like below however the code I am using with layer shadows makes the application LAGGY. I have not been able to find a good alternative solution. Does anyone have an alternative for creating a dropshadow that does not affect application performance?
[self.navController.view.layer setShadowOffset:CGSizeMake(0, 1)];
[self.navController.view.layer setShadowColor:[[UIColor darkGrayColor] CGColor]];
[self.navController.view.layer setShadowRadius:8.0];
[self.navController.view.layer setShadowOpacity:0.8];
上面的代码是我目前使用的代码导致应用程序性能问题。
The above code is the code I am currently using that causes application performance issues.
下图是我想要实现的,但无需使用上述代码。
The below image is what I would like to achieve but without having to use the above code.
推荐答案
它应该有助于指定阴影路径,例如,
It should help to specify a shadow path, e.g.,
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:self.navController.view.layer.bounds].CGPath;
[self.navController.view.layer setShadowPath:shadowPath]
根据 CALayer文档,指定显式路径通常可以提高渲染性能。
According to the CALayer documentation, "Specifying an explicit path usually improves rendering performance."
这篇关于iOS:创建一个侧面的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!