1

我有一个 UIView,我对其应用了图层蒙版。它适用于除视网膜 iPad 之外的所有设备。在视网膜 iPad 上,被遮盖的视图不显示。如果我取下遮罩,视图会显示在视网膜 iPad 上。

面具很简单。它显示了整个视图,除了从底部边缘取出的小三角形。

contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height - 50.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGMutablePathRef path = CGPathCreateMutable();
float triangleDepth = 10;
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, contentView.frame.size.width, 0);
CGPathAddLineToPoint(path, NULL, contentView.frame.size.width, contentView.frame.size.height);
CGPathAddLineToPoint(path, NULL, (contentView.frame.size.width / 2.0) + triangleDepth, contentView.frame.size.height);
CGPathAddLineToPoint(path, NULL, (contentView.frame.size.width / 2.0), contentView.frame.size.height - triangleDepth);
CGPathAddLineToPoint(path, NULL, (contentView.frame.size.width / 2.0) - triangleDepth, contentView.frame.size.height);
CGPathAddLineToPoint(path, NULL, 0, contentView.frame.size.height);
CGPathCloseSubpath(path);
[maskLayer setPath:path];
CGPathRelease(path);
contentView.layer.mask = maskLayer;
contentView.clipsToBounds = NO;
[self.view addSubview:contentView];

这段代码适用于每台设备,那么视网膜 iPad 有什么不同会阻止它工作呢?

4

1 回答 1

1

这只是 iOS 模拟器的一个问题。我终于在视网膜 iPad 上尝试了代码,一切正常。

于 2012-11-26T12:23:19.560 回答