我将答案中的代码复制到如何将透视图转换应用于UIView?,以获得以下图像。但是,请注意,将级别分隔开的锯齿状线条。有没有其他方式来执行这种透视图转换,以反别名这些锯齿状的线条?

编辑我尝试过DarkDust在这篇文章的评论中提供的解决方案。似乎都没有用。这是我的密码:
levelView = [[UIControl alloc] initWithFrame:CGRectMake(100, 60, 160, 230)];
[self addSubview:levelView];
levelView.transform = CGAffineTransformScale(self.transform, .8, .8);
CALayer *layer = levelView.layer;
//DarkDust's 2nd comment
layer.borderWidth = 1;
layer.borderColor = [[UIColor clearColor] CGColor];
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / 1000;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
for (NSString *ID in [NSArray arrayWithObjects:@"Level 1", @"Level 2", @"Level 3", @"Level 4", @"Level 5", nil]) {
//Note the offset of 5 from the superview in both X and Y directions. This addresses DarkDusk's first comment
UIControl *ctrl = [[UIControl alloc] initWithFrame:CGRectMake(5, y + 5, levelView.frame.size.width, 220/5)];
[levelView addSubview:ctrl];
[ctrl addTarget:self action:@selector(languageSelected:) forControlEvents:UIControlEventTouchDown];
[self styleEnabled:ctrl];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(13, 0, ctrl.frame.size.width - 13, ctrl.frame.size.height)];
[ctrl addSubview:label];
label.text = ID;
label.font = [UIFont systemFontOfSize:20];
label.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:.8];
label.backgroundColor = [UIColor clearColor];
y += ctrl.frame.size.height;
}在图像中看到的级别按钮都是UIControl的实例,它们是UIControl *levelView的直接子视图。levelView是一个正在被改变的。
DarkDusk的另外两个评论特别提到了UIImages,我没有使用它。如果它们仍然适用,并且有人可以解释如何实现它们,我肯定会给它们一个机会。
发布于 2014-09-22 08:58:54
iOS 7为CALayer带来了一个新的属性allowsEdgeAntialiasing,您可以看到这里。当设置为YES时,您的图层将使用反锯齿边缘进行转换.
/* When true this layer is allowed to antialias its edges, as requested
* by the value of the edgeAntialiasingMask property.
*
* The default value is read from the boolean UIViewEdgeAntialiasing
* property in the main bundle's Info.plist. If no value is found in
* the Info.plist the default value is NO. */
@property BOOL allowsEdgeAntialiasing;https://stackoverflow.com/questions/8863282
复制相似问题