问题描述
- UIScrollView图片比较大
-
下面代码显示了scrollView
,但是需要显示的图片(tutorial)比view大。
tutorial.png的尺寸是280X1200
。tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)]; tipScroll.showsVerticalScrollIndicator = YES; tipScroll.scrollEnabled = YES; tipScroll.userInteractionEnabled = YES; UIImageView *tutorialImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tutorial"]]; tipScroll.contentMode = UIViewContentModeScaleAspectFit; tutorialImageView.contentMode = UIViewContentModeScaleAspectFit; tipScroll.contentSize = tutorialImageView.frame.size; [self.view addSubview:tipScroll]; [tipScroll addSubview:tutorialImageView];
解决方案
试试:
tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)];
tipScroll.showsVerticalScrollIndicator = YES;
tipScroll.scrollEnabled = YES;
tipScroll.userInteractionEnabled = YES;
UIImageView *tutorialImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 280, 1200)];
tutorialImageView.image = [UIImage imageNamed:@"tutorial"];
tipScroll.contentSize = tutorialImageView.frame.size;
[tipScroll addSubview:tutorialImageView];
[self.view addSubview:tipScroll];
时间: 2024-10-06 00:00:38