下面代碼顯示了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];