In iOS, Uiscrollview inherits from UIView, extending the scrolling, zooming, and dual protocols, where the most common uitableview are inherited from the class.
Uiscrollview frame, bounds, contentsize, Contentoffset, and Contentinset properties, these properties have always been easy to confuse, their own small summary:
Frame is created based on the Superview coordinate system and represents the position of the scroll view in its parent view
The Bounds property is based on the coordinate system of the scrolling view itself and is primarily used to determine the position of its child view on the scroll view, and when the bounds property changes, its child views move (not commonly used on scrolling views)
Contentsize is a view that Uiscrollerview can scroll. Frame represents the size of the scrolling view itself, while contentsize represents the size that can be scrolled on a scrolling view, and when contentsize is smaller than frame, it cannot be scrolled, and when contentsize is larger than frame, it can be scrolled.
Contentoffset is the offset of the vertex of the current display area relative to the frame vertex, where bounds is a coordinate system change, contentoffset the coordinate system does not change, and the coordinates change
Contentinset's API documentation is interpreted as "the distance that the content view is embedded in the closed scrolling view." It can be understood that the size of the four edges of the content view is extended up or down. The Contentinset unit is uiedgeinsets, with the default value of Uiedgeinsetszero, which is the edge without expansion. The following explains Uiedgeinsets, which is a struct, defined as follows:
- typedef struct {
- CGFloat top, left, bottom, right;
- }
The values representing the upper boundary, the left boundary, the bottom boundary, the right boundary, and the extended value are respectively represented.
Borrow a picture from the Stanford University iphone tutorial
Contentsize, Contentoffset, and Contentinsert properties for Uiscrollview in iOS