![](/img/trans.png)
[英]Images not displayin on newer iPad devices like iPad Air, iPad3 but displaying on simulator iOS 8.1
[英]Layer Shadow Missing on iPad3 (but works in Simulator)
我使用以下代码在UIView后面绘制阴影
self.view.layer.borderColor = [UIColor whiteColor].CGColor;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
self.view.layer.shadowOpacity = 1.0;
self.view.layer.shadowRadius = 25.0;
self.view.layer.shadowOffset = CGSizeMake(0, 3);
self.view.clipsToBounds = NO;
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
[self.view.layer setShadowPath:shadowPath];
可以像在模拟器和iPhone5上那样工作。 但是在我的iPad3上:完全没有阴影。
知道怎么了吗?
我找到了解决方案。 这与模拟器无关。 这是关于肖像与风景园林方向界限的回归。 我必须将阴影路径的设置移动到viewDidAppear和didRotateFromInterfaceOrientation方法中,以使阴影在所有可能的启动方向上正确呈现。
-(void)viewDidAppear:(BOOL)animated{
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
[self.view.layer setShadowPath:shadowPath];
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
[self.view.layer setShadowPath:shadowPath];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.