圖片點(diǎn)擊放大,再次點(diǎn)擊返回原視圖.完美封裝,一個(gè)類一句代碼即可調(diào)用.IOS完美實(shí)現(xiàn)
導(dǎo)入頭文件
引入此類之后,為自己需要放大的imageView添加tap手勢(shì)
//
#import "ViewController.h"
#import "BCImageBrowser.h"
@interfaceViewController()<UIGestureRecognizerDelegate>
{
UIImageView*img;
}
@end
@implementationViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
img= [[UIImageView alloc]initWithFrame:CGRectMake(20,50,100,100)];
img.image= [UIImage imageNamed:@"ipon.jpg"];
img.userInteractionEnabled=YES;
UITapGestureRecognizer* PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(magnifyImage)];
PrivateLetterTap.numberOfTouchesRequired=1;//手指數(shù)
PrivateLetterTap.numberOfTapsRequired=1;//tap次數(shù)
PrivateLetterTap.delegate=self;
img.contentMode=UIViewContentModeScaleToFill;
[img addGestureRecognizer:PrivateLetterTap];
[self.view addSubview:img];
}
-(void)magnifyImage
{
NSLog(@"局部放大");
[BCImageBrowser showImage:img];//調(diào)用方法
}