iOS starts--ui UIView

Source: Internet
Author: User

Several main properties of UIView

1     /* 2      cgrect            frame; 3      4      cgrect            bounds; 5     6      cgpoint           Center; 7      8      cgaffinetransform transform; 9      */

Frame coordinates and length-width

Center Point

Bounds coordinate system limitations (?)

Deformation of the UIView

    //distortion of view ()//Direct DeformationView.transform = Cgaffinetransformmakescale (1,1); //rotational deformation passing in a radianView.transform =cgaffinetransformmakerotation (M_PI); /*     #define M_E 2.71828182845904523536028747135266250 e#define m_log2e 1.442695040888963407359924681001892 LOG2 (e) #define M_LOG10E 0.434294481903251827651128918916605082 log10 (e) #define M_LN2 0.693       147180559945309417232121458176568 Loge (2) #define M_LN10 2.30258509299404568401799145468436421 Loge (10) #define M_PI 3.14159265358979323846264338327950288 PI #define M_PI_2 1.5707963267948966192 3132169163975144 PI/2 #define M_PI_4 0.785398163397448309615660845819875721 PI/4 #define M_1 _PI 0.318309886183790671537767526745028724 1/pi #define M_2_PI 0.63661977236758134307553505349005744 8 2/pi #define M_2_SQRTPI 1.12837916709551257389615890312154517 2/sqrt (PI) #define M_SQRT2 1.41421      356237309504880168872420969808 sqrt (2) #define M_sqrt1_2 0.707106781186547524400844362104849039 1/sqrt (2)*/

    // Change the transparency    of the parent view // the transparency of the child view will also change      0.3;
//   When setting the sub-view out of range, cut    view.clipstobounds = NO;
    // Parent View Close view interaction     // The child view interaction is closed    after the interaction is closed view.userinteractionenabled = NO;

    // Subview is a child view    of view [View Addsubview:subview];
    // clicking outside of the parent view range  does not call    [Button addtarget:self action: @selector (printstring) forcontrolevents:uicontroleventtouchupinside];

If the two button has overlapping parts then click on the overlapping part of the click Method call is the top level is added later.

    //Arr Gets the parent view of the sub-view array at the bottom of the 0Nsarray * arr =view.subviews; //Changing the child view layer relationship is a method of parent views//move the view to the top of all sub-views *[View bringsubviewtofront:arr[0]]; //The handle view moves to the bottom of all the sub-views *[View sendsubviewtoback:arr[2]]; //Inserting a view into a view the first parameter is the view you want to move[View insertsubview:arr[2] Abovesubview:arr[1]]; //Insert a sub-view below a view[View insertsubview:arr[2] Belowsubview:arr[1]]; //insert a view into a layer position start at the bottom if the child view that you want to move is not added to the parent view, it is added to the parent view first[View insertsubview:arr[0] Atindex:1];

UIView Animation

//The animation starts here[UIView Beginanimations:nil Context:nil]; //set animation execution Time[UIView setanimationduration:1]; //set animation delay Execution Time[UIView Setanimationdelay:1]; //set up an animation agent[UIView setanimationdelegate:self]; //methods to execute after the animation finishes[UIView setanimationdidstopselector: @selector (ChangeView)]; //What the animation doesView.frame =Self.view.bounds; View.backgroundcolor=[Uicolor Greencolor]; //start the animation execution[UIView commitanimations];

Quick Setup

   //Block Animation//time Delay Select animated animation block method after execution of content execution ends[UIView animatewithduration:0.5Delay0Options:uiviewanimationoptionbeginfromcurrentstate animations:^{view.frame= CGRectMake (arc4random ()%415, Arc4random ()%737, Arc4random ()% $, Arc4random ()% $); View.center= Cgpointmake (arc4random ()%415, Arc4random ()%737); View.backgroundcolor= [Uicolor colorwithred:10000/(Arc4random ()%40000) Green:10000/(Arc4random ()%40000) Blue:10000/(Arc4random ()%10000) Alpha:0.8]; } Completion:^(BOOL finished) {[Self changeview]; }];

Changes to the child view when the docking mode parent view changes

    // to set the docking mode    of a child view Subview.autoresizingmask = uiviewautoresizingflexiblewidth| uiviewautoresizingflexibleheight;         /*      typedef ns_options (Nsuinteger, uiviewautoresizing) {     Uiviewautoresizingnone                 = 0,            no effect     Uiviewautoresizingflexibleleftmargin   = 1 << 0,       free left edit child view and parent view right spacing     unchanged Uiviewautoresizingflexiblewidth        = 1 << 1,       lateral spacing constant     uiviewautoresizingflexiblerightmargin  = 1 << 2,       free right edit     uiviewautoresizingflexibletopmargin    = 1 << 3,       free top edit bottom spacing unchanged     uiviewautoresizingflexibleheight       = 1 << 4,       vertical side spacing unchanged     Uiviewautoresizingflexiblebottommargin = 1 << 5        top spacing unchanged     };      */

About the slider control UISlider

    //Create a slider controlUISlider * slider = [[UISlider alloc]initwithframe:cgrectmake ( -, -, $, -)]; //left valueSlider.minimumvalue =0; //Right ValueSlider.maximumvalue = $; //set the initial valueSlider.value = $; //Add Sliding method uicontroleventvaluechanged value changes when ChangeValue is executed: Method[Slider addtarget:self action: @selector (ChangeValue:) forcontrolevents:uicontroleventvaluechanged];

iOS starts--ui UIView

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.