您的位置:首页 > 产品设计 > UI/UE

UIImageView上添加Button不能响应点击事件

2016-04-15 15:06 567 查看
UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-UITABBAR_HEIGHT-216-39, 320, 43) ];

[backImageView setUserInteractionEnabled:YES];//使添加其上的button有点击事件

[backImageView setImage:[UIImage imageNamed:@"navigationBar.png"]];

[backScroll addSubview:backImageView];

UIButton *loginButton = [UIButton alloc];

[loginButton setFrame:CGRectMake(10, 0, 40, 43)];

[loginButton setTitle:@"hello" forState:UIControlStateNormal];

[loginButton addTarget:self action:@selector(loginOrLogout) forControlEvents:UIControlEventTouchUpInside];

[backImageView addSubview:loginButton];

来源:http://blog.sina.com.cn/s/blog_9c3c519b0100yhfh.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: