在app里有些帮助文档,是一张长长的图片,如何简单的设置呢
- (void)addImageView {
//添加scrollview
UIScrollView *scro = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:scro];
//设置image
UIImage *img = [UIImage imageNamed:@"help"];
//获取图片像素
CGFloat fixelW = CGImageGetWidth(img.CGImage);
CGFloat fixelH = CGImageGetHeight(img.CGImage);
CGFloat mainWidth = self.view.frame.size.width;
CGFloat mainHeight = self.view.frame.size.width * fixelH/fixelW;
//设置contentsize
[scro setContentSize:CGSizeMake(mainWidth, mainHeight)];
//设置imageview
UIImageView *imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, mainWidth, mainHeight)];
[scro addSubview:imgview];
imgview.image = img;
}