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 }
開發(fā)工具Xcode5 系統(tǒng)版本:OS X 10. 9. 3 ( 13D65 )
posted on 2014-05-28 14:33
王海光 閱讀(349)
評論(0) 編輯 收藏 引用 所屬分類:
IOS