UIButton not firing selector if I draw it using CALayer
Posted
by Horatiu Paraschiv
on Stack Overflow
See other posts from Stack Overflow
or by Horatiu Paraschiv
Published on 2010-04-27T22:25:21Z
Indexed on
2010/04/28
0:23 UTC
Read the original article
Hit count: 546
Hi everybody I create this button like this:
_myButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
DLBadgeLayerDelegate *layerDelegate = [[DLBadgeLayerDelegate alloc] init];
_myButton.frame = CGRectMake(0.0 , 0.0, 100.0, 100.0);
[_myButton addTarget:self action:@selector(myButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
_myButton.layer.backgroundColor = [[UIColor redColor] CGColor];
_myButton.center = CGPointMake(10.0, 10.0);
[self addSubview:_myButton];
[_myButton release];
The button appears on the screen but if I tap on it nothing happens. If I just create a Rounded rect button instead with no custom drawing on its layer or if I just leave the layer line of code out all works well. Do you have any Idea why do I get this behaviour as I would like to do some custom drawing in the button's layer?
© Stack Overflow or respective owner