我将答案中的代码复制到How do I apply a perspective transform to a UIView?以获得以下图像。但请注意,锯齿线将水平分开。是否有必要以反锯齿这些锯齿线的方式进行这种视角转换?使用CATransform3DRotate时的抗锯齿行
编辑 我试着通过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,我不使用它。如果他们仍然适用,有人可以解释如何实施他们,我一定会给他们一个镜头。
的可能重复的[iPhone:CALayer的+在3D +反锯齿旋转](http://stackoverflow.com/questions/2686027/iphone-calayer-rotate-in-3d-antialias) – DarkDust 2012-01-14 16:11:36
参见重复。你可以通过简单的做'layer.borderWidth = 1; layer.borderColor = [[UIColor clearColor] CGColor];' – DarkDust 2012-01-14 16:13:41
另请参见[CALayer的抗混叠对角线边缘](http://stackoverflow.com/questions/6245276/anti-alias-diagonal-edges-of-calayer) – DarkDust 2012-01-14 16:15:47