我想在ipad应用程序中自动放大并缩小图像。例如,在启动画面中,它应该将图像显示为原始大小,一段时间后它应该自动开始缩小。这将为其提供动画放大/缩小外观。
我们如何在iPad中使用UIImageView做到这一点?
提前谢谢。
ScrollImageController.h
@interface ScrollImageViewController : UIViewController {
}
@end
ScrollImageController.m
- (void)viewDidLoad
{
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollView.contentSize = CGSizeMake(847, 800);
UIImage *image = [UIImage imageNamed:@"just.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
[image release];
[scrollView addSubview:imageView];
[imageView release];
[self.view addSubview:scrollView];
[scrollView setZoomScale:2.0 animated: YES];
[scrollView release];
}
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollView.contentSize = CGSizeMake(847, 800);
UIImage *image = [UIImage imageNamed:@"just.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
[image release];
[scrollView addSubview:imageView];
[imageView release];
[self.view addSubview:scrollView];
[scrollView setZoomScale:2.0 animated: YES];
[scrollView release];
答案 0 :(得分:0)
您应该将UIImageView作为UIScrollView的子视图
然后使用UIScrollViewDelegate创建类,然后使用以下方法。
[MyScrollView setZoomScale:(float)scale animated:YES];
编辑:我认为你不需要实现UIScrollViewDelegate协议