////HOMEPAGEVIEWCONTROLLER.M//Parkingproject////Created by Eric on 16/10/13.//copyright©2016 years Eric. All rights reserved.//#import "HomePageViewController.h"@interfaceHomepageviewcontroller () @property (nonatomic,strong) UIButton*Navibutton;@end@implementationHomepageviewcontroller-(void) Viewwillappear: (BOOL) animated{[Super viewwillappear:animated]; Self.naviButton.hidden=YES;}-(void) Viewdidappear: (BOOL) animated{[Super viewdidappear:animated]; [Self handlecaspringanimation];}- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.Self.navibutton =[UIButton Buttonwithtype:uibuttontypecustom]; Self.naviButton.frame= CGRectMake (kdevicewidth/2-Ten, $, the, -); [Self.navibutton settitle:@"Animation"Forstate:uicontrolstatenormal]; [Self.navibutton Setbackgroundcolor:[uicolor Orangecolor]; [Self.view AddSubview:self.naviButton]; }-(void) handlecaspringanimation{cgrect Screen=[UIScreen mainscreen].bounds; Catransform3d Move=catransform3didentity; CGFloat initalertviewyposition= (cgrectgetheight (screen) + cgrectgetheight (_navibutton.frame))/2; Move= Catransform3dmaketranslation (0,-initalertviewyposition,0); Move= Catransform3drotate (Move, +* m_pi/ the,0,0,1.0f); _navibutton.layer.transform=move; [UIView animatewithduration:1.0fDelay:0.0fusingspringwithdamping:0.4finitialspringvelocity:0.0foptions:uiviewanimationoptioncurvelinear Animations:^{Self.naviButton.hidden=NO; Catransform3d Init=catransform3didentity; _navibutton.layer.transform=Init; } Completion:^(BOOL finished) {}]; }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated. }-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event{[self handlecaspringanimation];}/*#pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before n avigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [s] Egue Destinationviewcontroller]. Pass the selected object to the new view controller.}*/@end
The key code is as above.
iOS drop rebound effect