CATransformLayer touch events handling

190 Views Asked by At

I have searched over the internet and Stackoverflow but i couldn't find any answer to this specific question, So here's my question,

I'm trying to create a double sided UIView which responds to touch events both sides(Such as UIButton, UISwitch, etc...). I have achieved that by adding two distinct CALayers to CATransformLayer. All works good but touches doesn't responds to the ui elements added from interface builder. To replicate the problem, i have created an UIView in the nib(frontView) added all ui elements from interface builder and add that UIView reference to CATransformLayer and all works good except it doesn't respond to touch events.

I understand that CALayer or CATransformLayer doesn't inherits from UIResponder class like UIView. And i believe there is a way to bring this layer to responder chain but i'm wondering how?. Below is my simplified problem code,

- (void)viewDidLoad
{
    [super viewDidLoad];

    CATransformLayer *myLayer = [[CATransformLayer alloc] initWithLayer:self.view.layer];
    myLayer.frame = CGRectMake(0, 0, 300, 300);
    [myLayer addSublayer:frontView.layer];//Here 'frontView' is a reference to UIView from nib file
    [self.view.layer addSublayer:myLayer];
}

Any support will greatly appreciate. Thanks in advance.

0

There are 0 best solutions below