IOS学习之 -- UIScrollView

#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIScrollView *myScorllView;
@property (strong, nonatomic) IBOutlet UIImageView *image;

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"a.jpg"]];
    self.myScorllView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    //重要的一项设置
    self.myScorllView.contentSize = self.image.bounds.size;
    [self.myScorllView addSubview:self.image];
    [self.view addSubview:self.myScorllView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

你可能感兴趣的:(IOS学习之 -- UIScrollView)