向兼容 iOS 3.0 的 UIView 添加轮廓阴影
我有两个 UIViewController A 和 B,它们作为子视图添加到 AppDelegate 中,B 位于 A 之上。
当点击 B 上的 UIButton 时,B 会滑向左侧,代码如下:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(slideOutFinished)];
simonSaysView.view.frame = CGRectMake(40-BView.view.frame.size.width, BView.view.frame.origin.y, BView.view.frame.size.width, BView.view.frame.size.height);
[UIView commitAnimations];
在右侧边缘,我想要一个 20px 的落差阴影,但我无法使用 BView.view.layer.shadow....
的阴影属性,因为它仅限于 3.2/4.0+。而且动画的表现很糟糕,幻灯片非常滞后(没有阴影很流畅)。
我正在考虑使用自定义 UIView 并在 drawRect 中做一些魔法,但这是否可能,或者我只能在视图的边界内绘制?
希望你们中的一些人可以帮助我。
干杯 对象新资料
I have two UIViewControllers A and B and they are added as subviews in the AppDelegate with B on top of A.
When a UIButton on B is tapped B slides off to the left with the following code:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(slideOutFinished)];
simonSaysView.view.frame = CGRectMake(40-BView.view.frame.size.width, BView.view.frame.origin.y, BView.view.frame.size.width, BView.view.frame.size.height);
[UIView commitAnimations];
On the right edge I want a 20px drop shadow but i cannot use the shadow properties of BView.view.layer.shadow....
because its 3.2/4.0+ only. And the performance of the animation is awful, the slide is lagging extremely much (Its fluent without the shadow).
I'm thinking using a custom UIView and do some magic in drawRect but is this possible or can i only draw within the bounds of the view?
Hope some of you guys and girls can help me.
Cheers
objneodude
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用下面的代码解决了
Solved with the following code
我遇到了同样的问题,在尝试了各种想法之后,我只是在 UIView 后面添加了一个阴影颜色(灰色)的子视图,我需要有一个阴影,请参阅代码:(包括> 3.2.x/4.x 的代码以及。
I had the same problem, after trying various ideas, I just added a subview a shadow colour (Gray) behind the UIView I needed to have a shadow, see code: (Included is the code for >3.2.x/4.x as well.