Ios iPad3上缺少层阴影(但可在模拟器中工作)
我使用以下代码在UIView后面绘制阴影Ios iPad3上缺少层阴影(但可在模拟器中工作),ios,objective-c,quartz-graphics,shadow,Ios,Objective C,Quartz Graphics,Shadow,我使用以下代码在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
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上:根本没有阴影
知道怎么回事吗?我找到了解决办法。这与模拟器无关。这是关于肖像画与风景画方向界限的回归。我必须将阴影路径的设置移动到viewdide和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];
}