图片放大缩小的区域点击事件代码例子
2013-01-25 10:10
295 查看
图片放大缩小的区域点击事件代码例子
比如我们有个中国地图,在北京这个区域放了一个button,当这张地图放大和缩小的时候,我们都能点击这个button触发北京里面的事件。
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
x = 1;
y = 1;
UIImage *image = [UIImage imageNamed:@"index_big.jpg"];
imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 1024, 768);
imageView.userInteractionEnabled = YES;
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 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;
}
比如我们有个中国地图,在北京这个区域放了一个button,当这张地图放大和缩小的时候,我们都能点击这个button触发北京里面的事件。
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
x = 1;
y = 1;
UIImage *image = [UIImage imageNamed:@"index_big.jpg"];
imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 1024, 768);
imageView.userInteractionEnabled = YES;
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 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;
}
相关文章推荐
- 图片放大缩小的区域点击事件代码例子
- 图片放大缩小的区域点击事件代码例子
- 图片放大缩小的区域点击事件代码例子
- 实现图片放大缩小,点击热点响应事件
- iPhone 上图片放大缩小的代码例子
- 关于iPad+iPhone上,图片放大缩小时都能点击此区域
- 实现图片放大缩小,点击热点响应事件
- 实现点击图片的放大缩小
- 指定区域的图片自动按比例缩小的js代码(防止页面被图片撑破)
- Android DIY之路 (一) 指定区域多图片合成 放大 缩小 镜像 旋转 等(转)
- angularjs点击图片放大显示,点击关闭缩小显示
- Android ImageView包含透明区域的图片点击事件处理
- Android TouchImage图片放大,缩小,点击还原,double点击放大 源码解析
- [jQuery]地图浏览:如何实现图片的放大缩小和点击之后的位置居中
- 快速实现图片点击放大缩小,支持url
- 图片点击放大,再次点击返回原视图.完美封装,一个类一句代码即可调用.IOS完美实现
- ECCMS下显示文章内容的图片时超出大小自动缩小,点击放大图片
- ImageView+ViewPager+PhotoView实现朋友圈图片点击全屏查看支持放大缩小
- 微信浏览器返回刷新,监听微信浏览器返回事件,网页防复制,移动端禁止图片长按和vivo手机点击img标签放大图片