2013-03-01 73 views
0

我用下面的代码双层阴影上缺少的iPad3(但在模拟器工作)

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的应该画一个UIView后面的阴影。但是在我的iPad3上:根本没有影子。

enter image description here

任何想法怎么来的?

回答

0

我找到了解决方案。这不是关于模拟器。这是关于人像与景观取向的界限的回归。我必须将阴影路径的设置移动到viewDidAppeardidRotateFromInterfaceOrientation方法中,以在所有可能的启动方向上正确渲染阴影。

-(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]; 
} 
相关问题