I am showing a UILabel in appdelegate file on navigation bar (Not exactly on navigation bar). It is showing perfect. But no touch event is calling on it. Touch is working only on status bar. Please help. Thanks in advance.
Here is my code.
CGRect frame=[[UIApplication sharedApplication] statusBarFrame];
backgroundImageView=[[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height, 320, 44)];
backgroundImageView.tag=50;
[backgroundImageView setTextAlignment:UITextAlignmentCenter];
[backgroundImageView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"music.png"]]];
[self.window addSubview:backgroundImageView];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"in touched");
}
As Tyler states in his answer here:
To intercept all touches you should use UIView subclass for your controller view and override hitTest:withEvent: method in it:
OR
2) You can use: