ios - 在视网膜 iPad 上应用图层蒙版隐藏所有

标签 ios ipad uiview mask cgpath

我有一个应用图层蒙版的 UIView。它适用于除视网膜 iPad 以外的所有设备。在 Retina iPad 上,被屏蔽的 View 不会显示。如果我取下 mask , View 会显示在视网膜 iPad 上。

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

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];

此代码适用于所有设备,那么 Retina iPad 有何不同之处会阻止此代码运行?

最佳答案

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

关于ios - 在视网膜 iPad 上应用图层蒙版隐藏所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13308693/

相关文章:

iPhone - 在 UITableView 上拖动会停止在后台渲染 OpenGL

iOS内存泄漏由于应用程序文档中存储的图像数量较多

iphone - 检测到长按时未调用 touchesEnded

ios - 我的角半径仅适用于一个角

iOS 设置包 : How to validate input

iOS Objective-C IBAction 两次运行方法中的代码

ios - 使用 NSString 更新 kABPersonPhoneProperty 以添加电话号码

iphone - objective-c :NSScanner扫描双重问题

iphone - 半透明的 UINavigationController,模态呈现

ios - 如何从 UIScrollView 中查找和替换 subview