之前就为了做这个图片放大缩小,模仿微信的,用手势的方法做的,很是麻烦 :
- [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
- CGRect wholeWindow = [self.window bounds];
- UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:wholeWindow];
- [[self window] addSubview:scrollView];
- CGRect reallyBigRect;
- reallyBigRect.origin = CGPointZero;
- reallyBigRect.size.width = wholeWindow.size.width *2.0;
- reallyBigRect.size.height = wholeWindow.size.height *2.0;
- [scrollView setContentSize:reallyBigRect.size];
- CGPoint offset;
- offset.x = wholeWindow.size.width *0.5;
- offset.y = wholeWindow.size.height*0.5;
- [scrollView setContentOffset:offset];
- [scrollView setMinimumZoomScale:0.5];
- [scrollView setMaximumZoomScale:2];
- [scrollView setDelegate:self];
- view = [[UIImageView alloc] initWithFrame:reallyBigRect];
- view.image = [UIImage imageNamed:@"123123123123"];
- [scrollView addSubview:view];
代理:
- - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
- {
- return view;
- }