Uiscrollview detailed _ios of IOS development

Source: Internet
Author: User

Introduction: Uiscrollview A control that displays a large content in a small area. View different content in this small area with user smoothing and hand gestures. is the parent class of UITableView and Uitextview. It's a view, but it's special, and it can be seen as a 2-tier structure. The above is its frame layer, like the general attempt, is its visible area, the following layer is Contentview, you can slide.

Parent class UIView method

Copy Code code as follows:

Autoresizingmask-now basic discard, switch to AutoLayout
typedef ns_options (Nsuinteger, uiviewautoresizing) {
Uiviewautoresizingnone = 0,//No automatic adjustment
Uiviewautoresizingflexibleleftmargin = 1 << 0,//automatically adjusted to the left side of Superview, the right distance remains unchanged
Uiviewautoresizingflexiblewidth = 1 << 1, automatically adjusts the width of the control itself to ensure that the left and right distance from the Superview
Uiviewautoresizingflexiblerightmargin = 1 << 2,//automatically adjusts to the right distance from Superview, left distance remains unchanged
Uiviewautoresizingflexibletopmargin = 1 << 3,//Auto adjust with superview top distance, bottom distance remain unchanged
Uiviewautoresizingflexibleheight = 1 << 4, automatically adjusts the height of the control itself to ensure that the upper and lower distance from the Superview
Uiviewautoresizingflexiblebottommargin = 1 << 5/Auto Adjust with Superview bottom distance, top distance remain unchanged
};
Transform-deformation attribute "structure-cannot be directly assigned"
Absolute position
Cgaffinetransformmakerotation (cgfloat angle);//Rotate
Cgaffinetransformmakescale (cgfloat sx, CGFloat sy);//Zoom
Cgaffinetransformmaketranslation (cgfloat tx, cgfloat ty);/move
Incremental modifications
Cgaffinetransformrotation (Cgaffinetransform t, cgfloat angle);/rotate
Cgaffinetransformscale (Cgaffinetransform T, cgfloat SX, CGFloat sy);//Zoom
Cgaffinetransformtranslation (Cgaffinetransform t, cgfloat tx, cgfloat ty);/move

Easily confusing attributes in Uiscrollview

Contentsize Content Dimensions
Contentinset Content Border Dimensions
Contentoffset Visual Box Offset
The difference between contentsize, Contentinset and Contentoffset

Uiscrollviewdelegate Proxy method

Copy Code code as follows:

will be invoked when scrolling, any way triggered contentoffset changes will be invoked, the call frequency is high
-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView;
Call when Start dragging
-(void) scrollviewwillbegindragging: (Uiscrollview *) ScrollView;
Call when Stop dragging
-(void) scrollviewdidenddragging: (Uiscrollview *) ScrollView withdecelerate: (BOOL) decelarate;
Call when scrolling is about to stop (called when drag and drop starts slowing down)
-(void) scrollviewwillbegindecelerating: (Uiscrollview *) ScrollView;
Call when scrolling stops, special case: When a deceleration animation is not finished, drag again and again, Didenddecelerating will not be called
-(void) scrollviewdidenddecelerating: (Uiscrollview *) ScrollView;
Called when scaling starts
-(void) scrollviewwillbeginzooming: (Uiscrollview *) ScrollView Withview: (UIView *) view;
Called when scaling is stopped
-(void) scrollviewdidendzooming: (Uiscrollview *) ScrollView Withview: (UIView *) View Atscale: (cgfloat) scale;
Called when scaling
-(void) Scrollviewdidzoom: (Uiscrollview *) ScrollView;
Basic usage of Uiscrollview
ScrollView = [[Uiscrollview alloc] Initwithframe:cgrectmake (0, 0, 320, 460)];
Scrollview.backgroundcolor = [Uicolor Redcolor];
Whether to support sliding at the top
Scrollview.scrollstotop = NO;
Scrollview.delegate = self;
Set content size, content border, visual offset
Scrollview.contentsize = Cgsizemake (320, 460*10);
Scrollview.contentinset = Uiedgeinsetsmake (0, 50, 50, 0);
Scrollview.contentoffset = Cgpointmake (50, 50);
Whether bounce
Scrollview.bounces = NO;
Whether paging
scrollview.pagingenabled = YES;
Whether to scroll
scrollview.scrollenabled = NO;
Set scroll bar style
Scrollview.indicatorstyle = Uiscrollviewindicatorstylewhite;
Set scroll bar edges
Scrollview.scrollindicatorinsets = Uiedgeinsetsmake (0, 50, 0, 0);
Controls whether scroll bars with horizontal orientation are displayed
Scrollview.showshorizontalscrollindicator = NO;
Control whether to display scroll bars in vertical direction
Scrollview.showsverticalscrollindicator = YES;
Set the range of ScrollView scaling
Scrollview.maximumzoomscale = 2.0; Max twice times
Scrollview.minimumzoomscale = 0.5;
Whether to move at the same time, lock
scrollview.directionallockenabled = YES;
[Self.view Addsubview:scrollview];

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.