In-depth research on Bounds

Source: Internet
Author: User

I. in-depth research on Bounds

1> frame: the origin is the upper left corner of the parent control, which describes the visible range of a region,

Bounds: indicates the origin where the visible range is displayed in the content range from the upper left corner of the content.

2> frame: the reference parent control remains unchanged.

Bounds: reference content, location changes

Note: When the value y of bounds increases, the content will move up! Why? As the value Y increases, the following content is displayed, so the content is moved up.

3> uiscrollview underlying implementation:

(1) create a uiview and add it to the view of the controller.

(2) Add a drag gesture to the uiview.

(3) call a method when dragging to change the bounds offset.

# Import "viewcontroller. H" @ interface viewcontroller () <uiscrollviewdelegate>
@ Property (weak, nonatomic) uiview * scrollview @ property (nonatomic, assign) cgpoint offsetx;
@ End @ implementation viewcontroller-(void) viewdidload {[Super viewdidload]; uiview * scrollview = [[uiview alloc] initwithframe: Self. view. bounds]; [self. view addsubview: scrollview]; _ scrollview = scrollview; optional * Pan = [[financialloc] initwithtarget: Self action: @ selector (Pan :)]; [scrollview addgesturerecognizer: Pan]; uiswitch * switchv = [[uiswitch alloc] init]; [scrollview addsubview: switchv];} // call it when dragging-(void) Pan :( uipangesturerecognizer *) pan {// obtain the offset cgpoint Transp = [Pan translationinview: Pan. view]; _ offsetx. X + =-Transp. x; _ offsetx. Y + =-Transp. y; _ scrollview. bounds = cgrectmake (_ offsetx. x, _ offsetx. y, self. view. bounds. size. width, self. view. bounds. size. height); [Pan settranslation: cgpointzero inview: Pan. view];}

 

In-depth research on Bounds

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.