Beautiful drop-down animation loading View

Source: Internet
Author: User

-(Ibaction) changepassword :( ID) sender

{

Cgsize size = [[uiscreen mainscreen] bounds]. size;

// Add a translucent Layer

Bgview = [[uiview alloc] initwithframe: Self. View. Frame];

Bgview. backgroundcolor = [uicolor colorwithwhite: 0.2 ALPHA: 0.7];

[Self. parentviewcontroller. View addsubview: bgview];

// Add the password modification window to the parent view because uitableview cannot directly add subview. Give the window an initial rotation angle.

Self. changepwd = [[self storyboard] instantiateviewcontrollerwithidentifier: @ "changepasswordid"];

Self. changepwd. Delegate = self;

[Self. changepwd. View setframe: cgrectmake (0,-200,280,200)];

[Self. changepwd. View settransform: cgaffinetransformmakerotation (-m_pi/20)];

[Self. parentviewcontroller. View addsubview: Self. changepwd. View];

// Animation loading password window

[Uiview animatewithduration: 0.3 animations: ^ {

[Self. changepwd. View settransform: cgaffinetransformmakerotation (0)];

[Self. changepwd. View setframe: cgrectmake (20, size. Height/2-100,280,200)];

}];

// Add a drag gesture to the window

Uipangesturerecognizer * panrecognizer = [[uipangesturerecognizer alloc] initwithtarget: Self action: @ selector (panpaswordview :)];

[Panrecognizer setminimumnumberoftouches: 1];

[Panrecognizer setmaximumnumberoftouches: 1];

[Self. parentviewcontroller. View addgesturerecognizer: panrecognizer];

}

 

-(Void) panpaswordview :( ID) sender {

[Self. View bringsubviewtofront: [(uipangesturerecognizer *) sender view];

Cgpoint translatedpoint = [(uipangesturerecognizer *) sender translationinview: Self. View];

// Record the center point of the floating window when dragging starts

If ([(uipangesturerecognizer *) sender State] = uigesturerecognizerstatebegan ){

Firstx = self. changepwd. View. Center. X;

Firsty = self. changepwd. View. Center. Y;

}

// Obtain the coordinates After dragging

Translatedpoint = cgpointmake (firstx, firsty + translatedpoint. y );

// Do not drag up

If (translatedpoint. Y <firsty ){

Return;

}

// Update the window position instantly when dragging

[Self. changepwd. View setcenter: translatedpoint];

// Close the password window when dragging ends and remove the additional gesture

If ([(uipangesturerecognizer *) sender State] = uigesturerecognizerstateended ){

[Self removepasswordview];

[Self. parentviewcontroller. View removegesturerecognizer :( uipangesturerecognizer *) sender];

}

}

 

-(Void) removepasswordview

{

[Uiview animatewithduration: 0.5 animations: ^ {

[Self. changepwd. View setframe: cgrectmake (20,113 6, 280,200)];

Bgview. Alpha = 0.0;

} Completion: ^ (bool finished ){

[Self. changepwd. View removefromsuperview];

[Bgview removefromsuperview];

}];

}

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.