回答からコードをコピーして、パースペクティブ変換を 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 の他の 2 つのコメントは、私が使用していない UIImages に関するものです。それらがまだ適用可能であり、誰かがそれらを実装する方法を説明できる場合、私は確かにそれらを試してみます.