我有一个UItoolbar和init,我的子视图有点超出工具栏框架。当我在不在工具栏框架中的区域中单击它们时,UITapGestureRecognizer不起作用。有可能做到这一点吗?这是我的工具栏的图像:
修改
代码:
UITapGestureRecognizer *koleckoTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addFell:)];
UITapGestureRecognizer *scoreTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
UITapGestureRecognizer *likesTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
UIImageView *scoreView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.view.frame)-90, -25, 60, 60)];
scoreView.image = [UIImage imageNamed:@"score"];
scoreView.userInteractionEnabled = YES;
[scoreView addGestureRecognizer:scoreTap];
scoreView.tag = 55885588856;
scoreView.layer.masksToBounds = YES;
UIImageView *likesView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.view.frame)+30, -25, 60, 60)];
likesView.image = [UIImage imageNamed:@"likes"];
likesView.userInteractionEnabled = YES;
[likesView addGestureRecognizer:likesTap];
likesView.tag = 55885588856;
UIImageView *mainView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.view.frame)-40, -45, 80, 80)];
mainView.image = [UIImage imageNamed:@"kolecko"];
mainView.userInteractionEnabled = YES;
[mainView addGestureRecognizer:koleckoTap];
mainView.tag = 55885588856;
mainView.clipsToBounds = YES;
mainView.layer.masksToBounds = YES;
//self.navigationController.toolbar.translucent = YES;
[self.navigationController.toolbar setBackgroundColor:[UIColor colorWithRed:33.0 / 255.0 green:157.0 / 255.0 blue:147.0 / 255.0 alpha:1.0]];
[self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"pruhledny.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
//self.toolbarItems=[NSArray arrayWithObjects:flexibleSpace,koleckoBar,flexibleSpace,nil];
[self.navigationController.toolbar insertSubview:scoreView atIndex:1];
[self.navigationController.toolbar insertSubview:likesView atIndex:2];
[self.navigationController.toolbar insertSubview:mainView atIndex:3];