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
原文地址:https://www.cnblogs.com/yangjingqi/p/4910086.html