Gesture Removal Controller
Similar to it home, QQ, QQ music removal controller
#import "NavigationController.h" @interface navigationcontroller ()/** Store every controller in full screen */@property(nonatomic,Strong)Nsmutablearray*images;@property(nonatomic,Strong)Uiimageview*lastvcview;@property(nonatomic,Strong)UIView*cover;@end @implementation navigationcontroller - (Uiimageview*) lastvcview{if(!_lastvcview) {UIWindow*window = [uiapplicationSharedapplication]. Keywindow;Uiimageview*lastvcview = [[UiimageviewALLOC] init]; Lastvcview. Frame= window. Bounds; Self. Lastvcview= Lastvcview; }return_lastvcview;} - (UIView*) cover{if(!_cover) {UIWindow*window = [uiapplicationSharedapplication]. Keywindow;UIView*cover = [[UIViewALLOC] init]; Cover. BackgroundColor= [UicolorBlackcolor]; Cover. Frame= window. Bounds; Cover. Alpha=0.5; Self. Cover= cover; }return_cover;} - (Nsmutablearray*) images{if(!_images) { Self. Images= [[NsmutablearrayALLOC] init]; }return_images;} - (void) Viewdidload {[SuperViewdidload];//Drag gesturesUipangesturerecognizer *recognizer = [[Uipangesturerecognizer alloc] Initwithtarget: SelfAction@selector(dragging:)]; [ Self. ViewAddgesturerecognizer:recognizer];} - (void) Dragging: (Uipangesturerecognizer *) recognizer{//If only 1 sub-controllers, stop dragging if( Self. Viewcontrollers. Count<=1)return;//distance traveled in x direction CGFloattx = [Recognizer Translationinview: Self. View]. x;if(TX <0)return;if(recognizer. State= = Uigesturerecognizerstateended | | Recognizer. State= = uigesturerecognizerstatecancelled) {//Decide whether to pop or restore CGFloatx = Self. View. Frame. Origin. x;if(x >= Self. View. Frame. Size. Width*0.5) { [UIViewAnimatewithduration:0.25animations:^{ Self. View. Transform= Cgaffinetransformmaketranslation ( Self. View. Frame. Size. Width,0); } completion:^ (BOOLFinished) {[ SelfPopviewcontrolleranimated:NO]; [ Self. LastvcviewRemovefromsuperview]; [ Self. CoverRemovefromsuperview]; Self. View. Transform= Cgaffinetransformidentity; [ Self. ImagesRemovelastobject]; }]; }Else{ [UIViewAnimatewithduration:0.25animations:^{ Self. View. Transform= Cgaffinetransformidentity; }]; } }Else{//Mobile View Self. View. Transform= Cgaffinetransformmaketranslation (TX,0);UIWindow*window = [uiapplicationSharedapplication]. Keywindow;//Add to Last face Self. Lastvcview. Image= Self. Images[ Self. Images. Count-2]; [Window Insertsubview: Self. LastvcviewAtindex:0]; [Window Insertsubview: Self. CoverAbovesubview: Self. Lastvcview]; }}/** * * Generation * *- (void) createscreenshot{Uigraphicsbeginimagecontextwithoptions ( Self. View. Frame. Size,YES,0.0); [ Self. View. LayerRenderincontext:uigraphicsgetcurrentcontext ()];UIImage*image = Uigraphicsgetimagefromcurrentimagecontext (); [ Self. ImagesAddobject:image];} - (void) Viewdidappear: (BOOL) animated{[SuperViewdidappear:animated];if( Self. Images. Count>0)return; [ SelfCreatescreenshot];} - (void) Pushviewcontroller: (Uiviewcontroller*) Viewcontroller Animated: (BOOL) animated{[SuperPushviewcontroller:viewcontroller animated:animated]; [ SelfCreatescreenshot];}@end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS Development-Gesture Remover Controller