#import "ViewController.h"
@interfaceViewController ()
// 展示图片不能压缩,如果展示不下(显示了图片的一部分),就拖动图片来展示其他的部分
@end
@implementation ViewController
- (void)viewDidLoad { [superviewDidLoad];
UIScrollView *scrollView = [[UIScrollViewalloc]initWithFrame:self.view.bounds];
// 0 指定scrollView滚动到这个位置 // CGPoin scrollView.contentOffset =tMake(100, 100); [self.viewaddSubview:scrollView];
UIImageView *imageView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"0.jpeg"]];
// 1 滚动的范围(scrollView能滚多远)没有设置这个属性,就不能滚动 scrollView.contentSize = CGSizeMake(imageView.image.size.width, imageView.image.size.height);
// 2 代码设置这个属性默认看不到效果,拖动松手之后才能看到效果 // scrollView.contentInset = UIEdgeInsetsMake(20, 20, 40, 80);
// 3 隐藏滚动条 scrollView.showsHorizontalScrollIndicator = NO; scrollView.showsVerticalScrollIndicator = NO;
// 4 弹簧效果 scrollView.bounces = NO;
[scrollView addSubview:imageView]; }
@end
|
原文:http://www.cnblogs.com/GhostKZShadow/p/5105487.html