1、先创建一个UIImageView控件:
1 photeImageView = [[UIImageView alloc]init]; 2 photeImageView.frame = CGRectMake(6*ScreenWidth/20, 0.5*Screenheight/20+64, 8*ScreenWidth/20, 8*ScreenWidth/20); 3 photeImageView.layer.cornerRadius = 4*ScreenWidth/20; 4 photeImageView.layer.masksToBounds = YES; 5 photeImageView.image = [UIImage imageNamed:@"22.jpg"];
2、初始化一个点击手势事件:
1 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choseImage:)];
3、把点击手势事件添加给1中创建好的UIImageView:
1 [photeImageView addGestureRecognizer:tap];
4、把UIImageView添加到当前VIew:
1 [self.view addSubview:photeImageView];
5、编写第二步中的点击事件ChoseImage::
1 -(void)choseImage:(UITapGestureRecognizer*)sender{ 2 //具体事件 3 }
完成。
这样就可以通过点击图片去设置头像等。