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