UIScrollView的常见属性

1.CGPoint contentOffset:用来表示UIScrollView滚动的位置

2.CGSize contentSize:用来表示UIScrollView内容的尺寸,滚动范围

3.UIEdgeInsets contentInset:能够在UIScrollView4周增加额外的滚动区域

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *mView;


- (IBAction)scroll;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
     self.scrollView.contentSize = self.mView.frame.size; // 总体内容的范围(滚动范围)
    
    self.scrollView.contentInset = UIEdgeInsetsMake(200, 400, 800, 1600);//设置内边距
   }
-(IBAction)scroll{ CGPoint offset = self.scrollView.contentOffset; offset.x+=10; offset.y+=10; [self.scrollView setContentOffset:offset animated:YES]; } @end

 

posted @ 2015-10-26 00:13  老树昏鸦  阅读(163)  评论(0编辑  收藏  举报