Custom Button on top of another custom button?

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-04-06T23:21:51Z Indexed on 2010/04/06 23:53 UTC
Read the original article Hit count: 271

Filed under:
|
|

I'm trying to make two custom buttons in code. One that fills the full screen with a small button on top. The problem I'm having is the larger button is triggered when the smaller button is tapped. I've tried doing exactly the same thing with IB and it works. Is there some sort of trapping/masking method that I need to use with code? I've checked the documentation and not come across anything that would suggest why this is happening.

CGRect bFrame = CGRectMake(0, 0, 320, 480);
UIButton *cancelButton = [[UIButton alloc] init];
cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
cancelButton.frame = bFrame;
[cancelButton setBackgroundColor:[UIColor clearColor]];
[cancelButton addTarget:self action:@selector(animate:) forControlEvents:UIControlEventTouchUpInside];      


UIButton *priceButton = [[UIButton alloc] init];
priceButton.center = CGPointMake(228, 98);
[priceButton addTarget:self action:@selector(callNumber:) forControlEvents:UIControlEventTouchUpInside];
[priceButton setTitle:@"BUY" forState:UIControlStateNormal];

//[cancelButton addSubview:priceButton];
[self.view addSubview:cancelButton];
[self.view bringSubviewToFront:priceButton];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uibutton