1、设置背景图片
1 UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(128, 80,64,64)];
2 imgView.image = [UIImage imageNamed:@"portrait.png"];
3 imgView.userInteractionEnabled=YES;
4 UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClickPortraitImage)];
5 [imgView addGestureRecognizer:singleTap];
6 [self.view addSubview:imgView];
2、响应点击事件
1 -(void)onClickPortraitImage{
2
3 NSLog(@"图片被点击!");
4 }
开发工具Xcode5 系统版本:OS X 10. 9. 3 ( 13D65 )
posted on 2014-05-28 14:33
王海光 阅读(334)
评论(0) 编辑 收藏 引用 所属分类:
IOS