Ios-github Dry Sharing (App guide page's highly integrated-Dhguidepagehud)

Source: Internet
Author: User

  For a long time did not update the blog, it is time to share a wave of dry goods; App Guide page does not say that every app will be used, the component is not heavy but indispensable, whether it is the first installation of the app or version of the update, the first show to the user is only it, of course, this is not the App guide page beautification but the high integration of the App guide page, Is it too much for a line of code to take care of the app's boot page? Let's take a look!

  (a) first on GitHub to save time (sharing is a virtue, star is a kind of encouragement; PS: Don't forget to take a second to tap the little star in the upper right corner of GitHub? Star, encourage the people who integrate the SDK?? ):

GitHub Address: Https://github.com/dingding3w/DHGuidePageHUD

  (ii) Display:

              

  (c) A line of code to take care of the creation of the App Guide page (really a line of code, just fill in the parameters):

1 /**2 * Dhguidepagehud3  *4 * @param frame position size5 * @param imagearray Guide page image array6 * @param Ishidden start to experience whether the button is hidden (YES: Hide-Boot page to complete the automatic access to the app homepage; No: Do not hide-boot page Complete Click the Start Experience button to go to the app homepage)7  *8 * @return Dhguidepagehud Object9  */Ten-(Instancetype) Dh_initwithframe: (CGRect) frame Imagearray: (Nsarray *) Imagearray Buttonishidden: (BOOL) IsHidden;

  (iv) Realization mode and principle:

The App guide page is composed of several pictures, the guide page of the picture in the art transduction will give you this do not worry, and make a number of pictures are scrolling, each drag will jump to the next guide page picture, then we must think of the view can be scrolled, I'm using Uiscrollview here.

    (1) Create a class that inherits from the UIView;

(2) Add the ScrollView of the setting boot view to the UIView;

1         //set the ScrollView of the boot view2Uiscrollview *guidepageview =[[Uiscrollview alloc]initwithframe:frame];3 [Guidepageview setbackgroundcolor:[uicolor lightgraycolor];4         //calculates the contentsize of a uiscrollview based on the number of incoming picture arrays5[Guidepageview Setcontentsize:cgsizemake (ddscreenw*Imagearray.count, Ddscreenh)];6 [Guidepageview Setbounces:no];7 [Guidepageview Setpagingenabled:yes];8 [Guidepageview Setshowshorizontalscrollindicator:no];9 [Guidepageview setdelegate:self];Ten[Self addsubview:guidepageview];

    (3) Add the Skip button in the upper right corner of the boot page (because the Skip button stays in the upper-right corner of the screen so it is also added on the UIView and is displayed above the Uiscrollview to enhance user interaction)

1         //Set the Skip button on the boot page2UIButton *skipbutton = [[UIButton alloc]initwithframe:cgrectmake (ddscreenw*0.8, ddscreenw*0.1, -, -)];3[Skipbutton Settitle:@"Skip over"Forstate:uicontrolstatenormal];4 [Skipbutton Settitlecolor:[uicolor Lightgraycolor] forstate:uicontrolstatenormal];5 [Skipbutton setbackgroundcolor:[uicolor graycolor];6[Skipbutton.layer Setcornerradius:5.0];7         //Add a Click event (the event stays with the Start Experience button to automatically jump to the app sync; The goal is to reduce the amount of code written and other ways to keep the sync style)8 [Skipbutton addtarget:self Action: @selector (ButtonClick:) forcontrolevents:uicontroleventtouchupinside];9[Self Addsubview:skipbutton];

    (4) Add multiple pictures on the boot page (if you set the Ishidden parameter to No, the "Start Experience button" will be added to the last boot page picture, and if you set the Ishidden parameter to Yes, When you swipe to the last app guide page, it automatically goes to the app homepage)

1        //add multiple boot pictures on the boot view2          for(intI=0; i<imagearray.count; i++) {3Uiimageview *imageview = [[Uiimageview alloc]initwithframe:cgrectmake (Ddscreenw*i,0, Ddscreenw, ddscreenh)];4Imageview.image =Imagearray[i];5 [Guidepageview Addsubview:imageview];6             7             //Settings Show the Enter Experience button on the last picture8             if(i = = imagearray.count-1&& Ishidden = =NO) {9 [ImageView Setuserinteractionenabled:yes];TenUIButton *startbutton = [[UIButton alloc]initwithframe:cgrectmake (ddscreenw*0.3, ddscreenh*0.8, ddscreenw*0.4, ddscreenh*0.08)]; One[Startbutton Settitle:@"Start the Experience"Forstate:uicontrolstatenormal]; A[Startbutton settitlecolor:[uicolor colorwithred:164/255.0Green201/255.0Blue the/255.0Alpha1.0] forstate:uicontrolstatenormal]; -[Startbutton.titlelabel Setfont:[uifont Systemfontofsize: +]]; -[Startbutton setbackgroundimage:[uiimage imagenamed:@"Guideimage.bundle/guideimage_button_backgound"] forstate:uicontrolstatenormal]; the [Startbutton addtarget:self Action: @selector (buttonclick:) forcontrolevents:uicontroleventtouchupinsid E]; - [ImageView Addsubview:startbutton]; -             } -}

   (5) Click on the implementation of the event, here use UIView animation and time-lapse way to use the App guide page to enter the app related to the fade effect of the homepage:

1- (void) ButtonClick: (UIButton *) button {2[UIView animatewithduration:ddhidden_time animations:^{3Self.alpha =0;4Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (Ddhidden_time * nsec_per_sec)), Dispatch_get_main_queue ( ), ^{5[Self performselector: @selector (Removeguidepagehud) Withobject:nil Afterdelay:1];6         });7     }];8}

    (6) Finally in the App guide page to jump to the app homepage, remember to remove the current App guide page, to prevent unnecessary trouble (preferably remove??):

1 -(void) removeguidepagehud {2    [self removefromsuperview]; 3 }

  (v) code that may be used:

    Here I use Nsuserdefaults to determine whether the program is first started (other methods can also, here the code for everyone to paste out)

1 if (! [[Nsuserdefaults Standarduserdefaults] boolforkey:boolforkey]) {2        [[nsuserdefaults standarduserdefaults] Setbool:yes Forkey:boolforkey]; 3         // write the code here to initialize the image array and the Dhguidepagehud Library boot page 4 }

  (vi) The above is my understanding and explanation of the third-party SDK of the Dhguidepagehud App guide page, all the code has been uploaded to the GitHub link (more star Star)??, hope that we complement each other to learn from each other;

Ios-github Dry Sharing (App guide page's highly integrated-Dhguidepagehud)

Related Article

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.