我有一个 UIView 用作标题,并且我已向该视图应用了阴影。它按照我的意图出现在屏幕上,但是在旋转之后,阴影变得暗了两倍,就好像它被重新绘制在自身之上一样。随后的旋转使其更暗。这是标题和阴影的代码:
self.header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEADER_HEIGHT)];
self.header.backgroundColor = [UIColor whiteColor];
self.header.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
// Drop shadow.
self.header.layer.shadowColor = [UIColor blackColor].CGColor;
self.header.layer.shadowOpacity = 0.5;
self.header.layer.shadowRadius = 2.0;
self.header.layer.shadowOffset = CGSizeMake(0, 2);
// self.header.layer.shouldRasterize = YES;
// self.header.layer.rasterizationScale = [UIScreen mainScreen].scale;
这段代码都发生在我的View Controller的viewWillLayoutSubviews中,在方法的开头调用了[super willLayoutSubviews]。我尝试将相同的代码放在 viewWillAppear:animated 中无效。