iOS boot page animations (packaged)

Source: Internet
Author: User

//directly on the code, on the outside as long as the call, the image array can be passed.//Created by Liu Zhiwu on 2016/12/3.//Copyright 2016 Zhiwuliu. All rights reserved.//#import"LaunchView.h"#defineL_base_tag 10000#defineL_rotate_rate 1#defineL_SCREEN_WIDHT [UIScreen mainscreen].bounds.size.width//Screen Width#definel_screen_height [UIScreen mainscreen].bounds.size.height//Screen Height@implementation Launchview-(Instancetype) initWithFrame: (cgrect) frame{ Self=[Super Initwithframe:frame]; if(self) {}returnSelf ;}//overriding the setter method of a picture array-(void) Setimagesarray: (Nsarray *) imagesarray{_imagesarray=Imagesarray; [Self creatsubviews];}-(void) creatsubviews{Nsarray*imagearr =[Nsarray Arraywitharray:_imagesarray]; Uiscrollview*mainscrollview = [[Uiscrollview alloc]initwithframe:cgrectmake (0,0, L_SCREEN_WIDHT, L_screen_height)]; Mainscrollview.pagingenabled=YES; Mainscrollview.bounces=NO; Mainscrollview.contentsize= Cgsizemake (l_screen_widht*Imagearr.count, l_screen_height); Mainscrollview.showshorizontalscrollindicator=NO; Mainscrollview.Delegate=Self ;        [Self addsubview:mainscrollview]; //Add a cloud pictureUiimageview *imageview = [[Uiimageview alloc]initwithframe:cgrectmake (0, the, L_SCREEN_WIDHT, the*l_screen_widht/1242.0)]; Imageview.image= [UIImage imagenamed:@"Yun.png"];            [Self addsubview:imageview];  for(intI=0; i<imagearr.count; i++) {UIView*rotateview = [[UIView alloc]initwithframe:cgrectmake (L_screen_widht*i,0, L_SCREEN_WIDHT, l_screen_height*2)]; [Rotateview Settag:l_base_tag+i];        [Mainscrollview Addsubview:rotateview]; if(i!=0) {Rotateview.alpha=0; } Uiimageview*imageview = [[Uiimageview alloc]initwithframe:cgrectmake (0,0, L_SCREEN_WIDHT, L_screen_height)]; Imageview.image=[UIImage Imagenamed:imagearr[i]];                [Rotateview Addsubview:imageview]; //last page Add button        if(i = = imagearr.count-1) {Uicontrol*control = [[Uicontrol alloc]initwithframe:cgrectmake (0, l_screen_height- the, L_SCREEN_WIDHT, -)]; Control.backgroundcolor=[Uicolor Blackcolor];            [Control addtarget:self Action: @selector (Clicktoremove) forcontrolevents:uicontroleventtouchupinside];        [Rotateview Addsubview:control]; }} UIView*firstview =[Mainscrollview Viewwithtag:l_base_tag];        [Mainscrollview Bringsubviewtofront:firstview]; }-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{UIView* View1 =[ScrollView Viewwithtag:l_base_tag]; UIView* View2 = [ScrollView viewwithtag:l_base_tag+1]; UIView* VIEW3 = [ScrollView viewwithtag:l_base_tag+2]; UIView* View4 = [ScrollView viewwithtag:l_base_tag+3]; Uiimageview* ImageView1 = (Uiimageview *) [ScrollView viewwithtag:l_base_tag*2]; Uiimageview* ImageView2 = (Uiimageview *) [ScrollView viewwithtag:l_base_tag*2+1]; Uiimageview* IMAGEVIEW3 = (Uiimageview *) [ScrollView viewwithtag:l_base_tag*2+2]; Uiimageview* ImageView4 = (Uiimageview *) [ScrollView viewwithtag:l_base_tag*2+3]; CGFloat Xoffset=Scrollview.contentoffset.x; //rotate based on offsetCGFloat Rotateangle =-1*1.0/L_SCREEN_WIDHT * Xoffset * m_pi_2 *l_rotate_rate; View1.layer.transform= Catransform3dmakerotation (Rotateangle,0,0,1); View2.layer.transform= Catransform3dmakerotation (m_pi_2*1+rotateangle,0,0,1); View3.layer.transform= Catransform3dmakerotation (m_pi_2*2+rotateangle,0,0,1); View4.layer.transform= Catransform3dmakerotation (m_pi_2*3+rotateangle,0,0,1); //displacement based on offset (guaranteed center point is always in the middle of the screen below)View1.center = Cgpointmake (0.5* l_screen_widht+Xoffset, l_screen_height); View2.center= Cgpointmake (0.5* l_screen_widht+Xoffset, l_screen_height); View3.center= Cgpointmake (0.5* l_screen_widht+Xoffset, l_screen_height); View4.center= Cgpointmake (0.5* l_screen_widht+Xoffset, l_screen_height); //which view is currently on top    if(xoffset<l_screen_widht*0.5) {[ScrollView bringsubviewtofront:view1]; }Else if(xoffset>=l_screen_widht*0.5&& Xoffset < l_screen_widht*1.5) {[ScrollView bringsubviewtofront:view2]; }Else if(Xoffset >=l_screen_widht*1.5&& Xoffset < l_screen_widht*2.5) {[ScrollView bringsubviewtofront:view3]; }Else if(Xoffset >=l_screen_widht*2.5) {[ScrollView bringsubviewtofront:view4]; }        //adjust its transparencyCGFloat Xoffset_more = xoffset*1.5>l_screen_widht? l_screen_widht:xoffset*1.5; if(Xoffset <l_screen_widht) {View1.alpha= (L_screen_widht-xoffset_more)/l_screen_widht; Imageview1.alpha= (L_screen_widht-xoffset)/l_screen_widht;; }    if(Xoffset <=l_screen_widht) {View2.alpha= Xoffset_more/l_screen_widht; Imageview2.alpha= Xoffset/l_screen_widht; }    if(Xoffset >l_screen_widht && xoffset <= l_screen_widht*2) {View2.alpha= (l_screen_widht*2-Xoffset)/l_screen_widht; View3.alpha= (XOFFSET-L_SCREEN_WIDHT)/l_screen_widht; Imageview2.alpha= (l_screen_widht*2-Xoffset)/l_screen_widht; Imageview3.alpha= (XOFFSET-L_SCREEN_WIDHT)/l_screen_widht; }    if(Xoffset >l_screen_widht*2) {View3.alpha= (l_screen_widht*3-Xoffset)/l_screen_widht; View4.alpha= (xoffset-l_screen_widht*2)/l_screen_widht; Imageview3.alpha= (l_screen_widht*3-Xoffset)/l_screen_widht; Imageview4.alpha= (xoffset-l_screen_widht*2)/l_screen_widht; }        //Adjust background color    if(Xoffset <l_screen_widht && xoffset>0) {Self.backgroundcolor= [Uicolor colorwithred: ( $-40.0/l_screen_widht*xoffset)/255.0Green: (255-25.0/l_screen_widht*xoffset)/255.0Blue: (255-100.0/l_screen_widht*xoffset)/255.0Alpha1]; }Else if(Xoffset>=l_screen_widht &&xoffset<l_screen_widht*2) {Self.backgroundcolor= [Uicolor colorwithred: ( -+30.0/l_screen_widht* (XOFFSET-L_SCREEN_WIDHT))/255.0Green: ( the-40.0/l_screen_widht* (XOFFSET-L_SCREEN_WIDHT))/255.0Blue: (155-5.0/ the* (XOFFSET-L_SCREEN_WIDHT))/255.0Alpha1]; }Else if(xoffset>=l_screen_widht*2&&xoffset<l_screen_widht*3) {Self.backgroundcolor= [Uicolor colorwithred: ( the-50.0/l_screen_widht* (xoffset-l_screen_widht*2))/255.0Green: ( the-40.0/l_screen_widht* (xoffset-l_screen_widht*2))/255.0Blue: ( Max+50.0/l_screen_widht* (xoffset-l_screen_widht*2))/255.0Alpha1]; }Else if(xoffset>=l_screen_widht*3&&xoffset<l_screen_widht*4) {Self.backgroundcolor= [Uicolor colorwithred: ( the-10.0/l_screen_widht* (xoffset-l_screen_widht*3))/255.0Green: ( Max-25.0/l_screen_widht* (xoffset-l_screen_widht*3))/255.0Blue: ( $-90.0/l_screen_widht* (xoffset-l_screen_widht*3))/255.0Alpha1]; }    }#pragmaButton's click Method-(void) clicktoremove{NSLog (@"Enter the main interface");} @end

iOS boot page animations (packaged)

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.