Fade animation
-(void) Viewdidload {
[Super Viewdidload];
[Self initcirclebtn];
}
-(void) Initcirclebtn {
Instantiate the gesture and eventually add the gesture to the circle button
Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc]initwithtarget:self Action: @selector (Handlepan:)];
Instantiate a circular button
UIButton *circlebtn = [[UIButton alloc]init];
Circlebtn.bounds = CGRectMake (0, 0, 100, 100);
Circlebtn.center = Self.view.center;
Circlebtn.backgroundcolor = [Uicolor Redcolor];
CircleBtn.layer.cornerRadius = Cgrectgetwidth (circlebtn.frame)/2;
[Circlebtn Addgesturerecognizer:pan];
[Circlebtn addtarget:self Action: @selector (Handledown:) Forcontrolevents:uicontroleventtouchdown];
[Self.view ADDSUBVIEW:CIRCLEBTN];
}
-(void) Handlepan: (Uipangesturerecognizer *) Recognizer {
Cgpoint translation = [recognizer TranslationInView:self.view];
Recognizer.view.center = Cgpointmake (recognizer.view.center.x + translation.x, Recognizer.view.center.y + TRANSLATION.Y);
[Recognizer Settranslation:cgpointmake (0, 0) InView:self.view]; //This is important because Handlepan: it will continue to be called, and the button will move very quickly if the displacement generated by the last call to the method is not zeroed .
//When you let go, start the decay animation
if (recognizer.state = = uigesturerecognizerstateended) {
Cgpoint velocity = [recognizer VelocityInView:self.view]; //Get let go when gesture in controller view speed
Popdecayanimation *popanimation = [Popdecayanimation animationwithpropertynamed:kpoplayerposition]; //Instantiate attenuation animation, which acts on position
[Popanimation Setvelocity:[nsvalue valuewithcgpoint:velocity]; //Set the initial speed of the Falloff animation
[Recognizer.view pop_addanimation:popanimation forkey:@ "Suibian"]; //Add falloff Animation to circular button
}
}
Basic use of attenuation animations for IOS pop animations