方法有点笨。 总的来说就是计算放到后图片的尺寸,然后算出放大倍数。把初始坐标放大
设两个变量
float x;
float y;
- (voID)vIEwDIDLoad { [super vIEwDIDLoad]; x = 1; y = 1; UIImage *image = [UIImage imagenamed:@"index_big.jpg"]; imageVIEw = [[UIImageVIEw alloc] initWithImage:image]; imageVIEw.frame = CGRectMake(0,1024,768); imageVIEw.userInteractionEnabled = YES; scrollVIEw = [[UIScrollVIEw alloc] initWithFrame:CGRectMake(0,768)]; scrollVIEw.contentSize = CGSizeMake(imageVIEw.frame.size.wIDth,imageVIEw.frame.size.height); scrollVIEw.maximumZoomScale = 3.0; scrollVIEw.minimumZoomScale = 1.0; scrollVIEw.delegate = self; [self.vIEw addSubvIEw:scrollVIEw]; [self.vIEw bringSubvIEwToFront:scrollVIEw]; [scrollVIEw addSubvIEw:imageVIEw]; [scrollVIEw bringSubvIEwToFront:imageVIEw];} - (voID)vIEwDIDAppear:(BOol)animated { [super vIEwDIDAppear:YES]; uabutton = [UIbutton buttonWithType:UIbuttonTypeCustom]; uabutton.frame = CGRectMake(731*x,235*y,130,60); [uabutton setTag:1]; [uabutton addTarget:self action:@selector(clickbutton:) forControlEvents:UIControlEventtouchUpInsIDe]; [imageVIEw addSubvIEw:uabutton];} #pragma mark -#pragma mark vIEw zoom- (UIVIEw *)vIEwForZoomingInScrollVIEw:(UIScrollVIEw *)scrollVIEw { return imageVIEw;} - (voID)scrollVIEwDIDEndZooming:(UIScrollVIEw *)scrollVIEw withVIEw:(UIVIEw *)vIEw atScale:(float)scale{ NSLog(@"scrollVIEwDIDEndZooming wIDth:%f,height:%f",imageVIEw.frame.size.wIDth,imageVIEw.frame.size.height); x = imageVIEw.frame.size.wIDth/1024; y = imageVIEw.frame.size.height/768;}总结
以上是内存溢出为你收集整理的关于iPad+iPhone上,图片放大缩小时都能点击此区域全部内容,希望文章能够帮你解决关于iPad+iPhone上,图片放大缩小时都能点击此区域所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)