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