ios開発–画面のスクロールを管理するクラスUIScrollView

1.プロパティ紹介
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
CGFloat screenH = [UIScreen mainScreen].bounds.size.height;
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, screenW,screenH)];
//CGSize
scrollView.contentSize = CGSizeMake(screenW,screenH);
//CGPoint
scrollView.contentOffset = CGPointMake(100, 100);
//UIEdgeInsets
scrollView.contentInset = UIEdgeInsetsMake(0, 0, 20, 20);
//BOOL
scrollView.bounces = NO;
//BOOL
scrollView.scrollEnabled = NO;
//BOOL
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
2.サンプルコード
UIScrollView *sv = [[UIScrollView alloc] initWithFrame:self.view.bounds];
sv.backgroundColor = [UIColor cyanColor];

UIView *uv = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1000, 1000)];
[sv addSubview:uv];
sv.contentSize = uv.bounds.size;
[self.view addSubview:sv];

IOS

Posted by arkgame