-(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];
}];
}