All three are UIScrollView properties, but of different types:

ObjectivC@property(nonatomic) CGSize contentSize
struct CGSize { CGFloat width; CGFloat height; };
@property(nonatomic) CGPoint contentOffset
struct CGPoint { CGFloat x; CGFloat y; };
@property(nonatomic) UIEdgeInsets contentInset
typedef struct { CGFloat top, left , bottom, right ; } UIEdgeInsets;
  • contentSizeIs a property in the ScrollView that represents the displayable area of the ScrollView. If you have a ScrollView, its frame is (0,0,320,480) and its contentSize is (320,960). In other words, the entire content size of this ScrollView is (320,960), and you need to scroll up and down to see the content after (320,480).
  • contentOffsetIs the offset of the scrollView’s current display area’s vertex from the frame’s vertex. For example, in the last example if you pulled it down, the contentoffSet would be (0,-480), which means that y is offset by 480. The default point for a CondentoffSet is CGPointZero
  • contentInsetDifficult to understand, it uses four values to indicate the position of the ContentView relative to the ScrollView. Look at the picture.

It is worth noting:

1. The contentOffSet coordinate value will change as the user slides the content view. 2. When the contentOffSet of the content view is negative, it is not visible in the scroll view.

These three properties are used together to determine the position of the ContentView in the ScrollView:

  • contentViewWhen there is no scrolling, the position of the contentView is known by the distance between the scrollView and /.left.
  • contentViewWhen scrolling, we can know the distance between the top left corner of contentView and the top left corner of scrollView by the coordinate of contentoffSet, and then we can know the specific position of contentView by the contentSize.
  • contentViewScroll to the end position, fixed in contentInset right/bottom 2 position;

The text description is too boring, specifically see the picture I drew: