に追加されたビュー レイヤーのタッチ イベントを有効にする方法はありCAReplicatorLayerますか?
に を追加しUIButtonてCAReplicatorLayerいます。ボタンの元のインスタンスと複製されたインスタンスの両方をタップ可能にしたいと考えています。
UIView -hitTest:withEvent:これまでのところ、ボタンへの転送とメソッドを試しまし-touchesXXX:withEvent:たが、まだ何も機能していません (これが可能であれば)。
からUIViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
static UIButton *button; // Temp hack to keep a ref to the button
button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(30, 100, 60, 44);
[button setTitle:@"Button" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
CAReplicatorLayer *layer = [CAReplicatorLayer layer];
layer.frame = self.view.bounds;
layer.instanceCount = 2;
layer.instanceTransform = CATransform3DMakeTranslation(70, 0, 0);
[layer addSublayer:button.layer];
[self.view.layer addSublayer:layer];
}
- (void)buttonTapped:(id)sender
{
NSLog(@"Tapped");
}