纯代码和storyboard都可以()
建一个继承自UINavigationController的类
以下是.m文件
//
// PanGestureBaseViewController.m
// TranslationEncapsulation
//
// Created by 银羽2 on 15/12/27.
// Copyright © 2015年银羽2. All rights reserved.
//
#import "PanGestureBaseViewController.h"
#define kWindow [[UIApplication sharedApplication] keyWindow]
#define kScreenWidth self.view.bounds.size.width
static constfloat kDurationTime =0.3;
static constfloat kScaleValue =0.95;
@interface PanGestureBaseViewController ()
{
CGPoint startTouch;//拖动开始时的位置
BOOL isMoving; //是否在拖动中
UIView *blackMask;
UIImageView *lastScreenShotView;
}
@property (strong,nonatomic)UIView *backgroundView;//背景
@property (strong,nonatomic)NSMutableArray *screenShotsList;//存截
@end
@implementation PanGestureBaseViewController
- (void)viewDidLoad {
[superviewDidLoad];
//初始化数组
self.screenShotsList = [NSMutableArrayarray];
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizeralloc]initWithTarget:selfaction:@selector(handlePanGesture:)];
[self.viewaddGestureRecognizer:panGesture];
self.navigationBar.hidden =YES;
isMoving = NO;
}
-(void)addLastScreenShotView
{
if (lastScreenShotView)[lastScreenShotViewremoveFromSuperview];
UIImage *lastScreenShot = [self.screenShotsListlastObject];
//把截图插入到backgoundView上,并黑色的背景下面
lastScreenShotView = [[UIImageViewalloc]initWithImage:lastScreenShot];
[self.back