简体   繁体   English

iPad3上缺少图层阴影(但可在模拟器中使用)

[英]Layer Shadow Missing on iPad3 (but works in Simulator)

I draw a shadow behind a UIView using the following code 我使用以下代码在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];

This works as supposed in the Simulator and on the iPhone5. 可以像在模拟器和iPhone5上那样工作。 However on my iPad3: No Shadow at all. 但是在我的iPad3上:完全没有阴影。

在此处输入图片说明

Any idea how come? 知道怎么了吗?

I found the solutions. 我找到了解决方案。 It wasn't about the Simulator. 这与模拟器无关。 It was about the return of bounds in portrait vs. landscapt orientation. 这是关于肖像与风景园林方向界限的回归。 I had to move the setting of the shadow path into the viewDidAppear and the didRotateFromInterfaceOrientation method to have the shadow render correctly in all possible startup orientations. 我必须将阴影路径的设置移动到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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 图像未显示在较新的iPad设备(如iPad Air,iPad3)上,但显示在模拟器iOS 8.1上 - Images not displayin on newer iPad devices like iPad Air, iPad3 but displaying on simulator iOS 8.1 在iPad Simulator上可用,但在iPad上崩溃 - Works on iPad Simulator but crashes on iPad AVExportSession可在Simulator,iPad 2而非iPad 4上运行 - AVExportSession works on Simulator, iPad 2 but not iPad 4 应用程式可在模拟器上运作,但不适用于iPad - App works on simulator but not on iPad 在iPad3上运行应用程序时,在模拟器上没有变量,但变量没有显示。 斯威夫特4 - I get nil on a variable when running app on iPad3 but not on simulator. Swift 4 iOS:Over The Air发行版适用于iPad1(iOS 5),但不适用于iPad3(iOS 6) - iOS: Over The Air distribution works on iPad1 (iOS 5) but not on iPad3 (iOS 6) NSDateFormatter stringFromDate在模拟器中无法在iPad上使用 - NSDateFormatter stringFromDate works in simulator not on iPad MutliTouch可在iPad Simulator上运行,但不能在设备上运行 - MutliTouch Works on iPad Simulator, but not devices JayData / Phonegap可在iPad Simulator中使用,但不适用于iPad设备 - JayData / Phonegap works in iPad Simulator but not iPad device iPad2应用程序可以在iPad3上运行吗? - Will iPad2 app work on iPad3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM