Contentsize, Contentoffset, and Contentinset properties for Uiscrollview in iOS

Source: Internet
Author: User

In iOS, Uiscrollview is a scrollable view, with the most commonly used UITableView inheriting uiscrollview.

Like all view, Uiscrollview has a frame property, and Uiscrollview also has contentsize, Contentoffset, and Contentinset properties. I was in the study, I think that contentsize and contentoffset relatively good understanding of the contentinset is a bit less good understanding. Here is a specific explanation.

Contentsize is an area where uiscrollview can scroll. In my understanding, I think of uiscrollview as a composite view with the upper and lower layers, frame control the size of the upper layer, we see the size of the Uiscrollview is actually the size of the frame, the upper fixed, the display of changes, from the lower scroll to control. The size of the lower-level scrolling area is controlled by the contentsize. For example: if frame = (0, 0, 480) contentsize = (320, 960), the Uiscrollview can scroll up and down, and the scrolling area is twice times the size of the frame.

Contentoffset is the offset of the vertex of the current display area relative to the frame vertex, for example, if the above example is pulled to the bottom, the Contentoffset is (0, 480), that is, Y is offset by 480.

Contentinset's API documentation is interpreted as "the distance that the content view is embedded in the closed scrolling view" (Ha, the English is not very good, the translation is bad). 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:

[CPP]View Plaincopy
    1. typedef struct {
    2. CGFloat top, left, bottom, right;
    3. }


The values representing the upper boundary, the left boundary, the bottom boundary, the right boundary, and the extended value are respectively represented.


Combined with this picture, it is better to understand the meaning of these values. The following is a picture of the Stanford University's iphone Open class on Uiscrollview, which can help understand.

Contentsize, Contentoffset, and Contentinset properties for Uiscrollview in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.