1
考慮下面的視圖層次最前面的可見UIView沒有收到觸摸,爲什麼?
- self.view
- self.transformedView(z變換= 10,索引0)
- self.ordinaryView(z變換= 0,索引1)
投入到生活這段代碼
@interface AGSTransformedView : UIView
@end
@implementation AGSTransformedView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"The transformed view is receiving touch");
[super touchesBegan:touches withEvent:event];
}
@end
@interface AGSOrdinaryView : UIView
@end
@implementation AGSOrdinaryView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"The ordinary view is receiving touch");
[super touchesBegan:touches withEvent:event];
}
@end
@interface AGSViewController()
@end
@implementation AGSViewController
- (void)viewDidLoad
{
[super viewDidLoad];
AGSTransformedView *transformed = [[AGSTransformedView alloc] initWithFrame:self.view.bounds];
transformed.layer.transform = CATransform3DMakeTranslation(0, 0, 10);
transformed.backgroundColor = [UIColor yellowColor];
[self.view addSubview:transformed];
AGSOrdinaryView *ordinary = [[AGSOrdinaryView alloc] initWithFrame:self.view.bounds];
ordinary.backgroundColor = [UIColor blueColor];
[self.view addSubview:ordinary];
}
@end
當屏幕上敲擊,我在我的控制檯
The ordinary view is receiving touch
看到這個在屏幕上,我只看到了黃色的視圖(變換視圖)。
爲什麼doesen't最前面的可見視圖接受觸摸?