//
// SlideViewController.h
// qqcehua
//
// Created by 张秀清 on 15/5/25.
// Copyright (c) 2015年 张秀清. All rights reserved.
// #import <UIKit/UIKit.h> @interface SlideViewController : UIViewController
{
@private
UIViewController *leftViewControl;
UIViewController *mainViewControl; CGFloat scalef;//缩小系数
} //滑动速度系数-建议在0.5-1之间。默认为0.5
@property (assign,nonatomic) CGFloat speedf; //是否允许点击视图恢复视图位置。默认为yes
@property (strong) UITapGestureRecognizer *sideslipTapGes; -(instancetype)initWithLeftViewController:(UIViewController *)leftViewController mainViewController:(UIViewController *)mainViewController; @end //
// SlideViewController.m
// qqcehua
//
// Created by 张秀清 on 15/5/25.
// Copyright (c) 2015年 张秀清. All rights reserved.
// #import "SlideViewController.h" @interface SlideViewController () @end @implementation SlideViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
} -(instancetype)initWithLeftViewController:(UIViewController *)leftViewController mainViewController:(UIViewController *)mainViewController
{
if (self = [super init])
{
self.speedf = 0.5; leftViewControl = leftViewController;
mainViewControl = mainViewController; //滑动手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[mainViewControl.view addGestureRecognizer:pan]; self.sideslipTapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
self.sideslipTapGes.numberOfTapsRequired = 1; [mainViewControl.view addGestureRecognizer:self.sideslipTapGes]; leftViewControl.view.hidden = YES; [self.view addSubview:leftViewControl.view];
[self.view addSubview:mainViewControl.view];
}
return self;
} #pragma mark - 滑动手势
-(void)handlePan:(UIPanGestureRecognizer *)panGesture
{
CGPoint point = [panGesture translationInView:self.view]; scalef = (point.x*self.speedf+scalef);//缩小系数 if (panGesture.view.frame.origin.x >=0)//向右滑
{
panGesture.view.center = CGPointMake(panGesture.view.center.x + point.x*self.speedf, panGesture.view.center.y);
/*
CGAffineTransformIdentity,每次变换前都要置位,不然你变换用的坐标系统不是屏幕坐标系统(即绝对坐标系统),而是上一次变换后的坐标系统
*/
panGesture.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1-scalef/1000, 1-scalef/1000);//缩小图片
[panGesture setTranslation:CGPointMake(0, 0) inView:self.view];//移动以后的坐标 leftViewControl.view.hidden = NO;
} if (panGesture.state == UIGestureRecognizerStateEnded)
{
if (scalef>100*self.speedf)
{
[self showLeftView];
}
else
{
[self showMainView];
scalef = 0;
}
}
} #pragma mark - 单击手势
-(void)handleTap:(UITapGestureRecognizer *)tapGesture
{
if (tapGesture.state == UIGestureRecognizerStateEnded) {
[UIView beginAnimations:nil context:nil];
tapGesture.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
tapGesture.view.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
[UIView commitAnimations];
scalef = 0; }
} #pragma mark - 修改视图位置
//恢复位置
-(void)showMainView{
[UIView beginAnimations:nil context:nil];
mainViewControl.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
mainViewControl.view.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
[UIView commitAnimations];
} //显示左视图
-(void)showLeftView{
[UIView beginAnimations:nil context:nil];
mainViewControl.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.8,0.8);
mainViewControl.view.center = CGPointMake(340,[UIScreen mainScreen].bounds.size.height/2);
[UIView commitAnimations]; }
@end

手势仿QQ侧滑---秀清的更多相关文章

  1. android开发学习 ------- 仿QQ侧滑效果的实现

    需要做一个仿QQ侧滑删除的一个效果: 一开始是毫无头绪,百度找思路,找到  https://blog.csdn.net/xiaxiazaizai01/article/details/53036994  ...

  2. iOS仿QQ侧滑菜单、登录按钮动画、仿斗鱼直播APP、城市选择器、自动布局等源码

    iOS精选源码 QQ侧滑菜单,右滑菜单,QQ展开菜单,QQ好友分组 登录按钮 3分钟快捷创建高性能轮播图 ScrollView嵌套ScrolloView(UITableView .UICollecti ...

  3. 仿QQ侧滑菜单<大自然的搬运工-代码不是我的>

    1.记录下效果图 2.二个工具类 package myapplication.com.myapplicationfortest.utils; import android.util.Log; /** ...

  4. OC仿QQ侧滑

    之前做侧滑用的控件的DDMenu,总感觉好像差了点什么,自己尝试写了一个,三层叠加,感觉效果不理想,偶然间看到了一篇博客,与大家分享,再次申明,该代码不是我写的,只是为了给自己留一个查找资料的机会 下 ...

  5. 自定义控件学习——仿qq侧滑栏

    效果 主要步骤: 1. 在xml布局里摆放内容. include    2. 在自定义ViewGroup里, 进行measure测量, layout布局    3. 响应用户的触摸事件    4. i ...

  6. 小程序仿QQ侧滑例子

    缩放:wxml <!--page/one/index.wxml--> <view class="page"> <view class="pa ...

  7. 如鹏网仿QQ侧滑菜单:ResideMenu组件的使用笔记整理+Demo

    ResideMenu菜单 课堂笔记: https://github.com/SpecialCyCi/AndroidResideMenu Github:如何使用开源组件1. 下载 下载方式: 1. 项目 ...

  8. 史上最简单,一步集成侧滑(删除)菜单,高仿QQ、IOS。

    重要的话 开头说,not for the RecyclerView or ListView, for the Any ViewGroup. 本控件不依赖任何父布局,不是针对 RecyclerView. ...

  9. android 自定义scrollview 仿QQ空间效果 下拉伸缩顶部图片,上拉回弹 上拉滚动顶部title 颜色渐变

    首先要知道  自定义scrollview 仿QQ效果 下拉伸缩放大顶部图片 的原理是监听ontouch事件,在MotionEvent.ACTION_MOVE事件时候,使用不同倍数的系数,重置布局位置[ ...

随机推荐

  1. win10系统微软账号登陆错误报错误码0x80190001

    https://blog.csdn.net/u012878537/article/details/91353248 使用onenote同步的时候报出这样的错误. 知道问题出在了哪里,就容易解决了不是. ...

  2. debian8.4系统安装后的一些设置

    1.添加软件源  su到root用户vi  /etc/apt/sources.list      也可用gedit  /etc/apt/sources.list   (gnome下用,如果kde下则用 ...

  3. php.ini配置文件中设置时区

    date.timezone设置php5默认date.timezone为utc,改为date.timezone = PRC即可解决时间相差八小时的问题

  4. scrollTop、scrollHeight与clientHeight

    MDN上概念 scrollTop:获取或设置一个元素的内容垂直滚动的像素数. scrollHeight:一个元素内容高度的度量,包括由于溢出导致的视图中不可见内容. clientHeight:元素内部 ...

  5. POJ3090Visible Lattice Points

    http://poj.org/problem?id=3090 对于此题,观测点的数目,从小规模开始观察,可以得到每一个点,由一根无限长的绳子,绕着原点旋转,得到的第一个点.换另外一个思路,每一个观察到 ...

  6. HDU分拆素数和

    https://acm.hdu.edu.cn/showproblem.php?pid=2098 时间复杂度 #include<bits/stdc++.h> using namespace ...

  7. springBoot--原理分析

    起步依赖分析 分析spring-boot-starter-parent 按住Ctrl点击pom.xml中的spring-boot-starter-parent,跳转到了spring-boot-star ...

  8. vmware快速扩容虚拟磁盘

    在使用vmware进行虚拟化的时候,会遇到虚拟磁盘不够用的情况,以前的办法都是使用lvm进行管理扩容,目前在linux上可以实现快速扩容了,具体方法如下: 该方法参考阿里云在线扩容文档:文档地址 其中 ...

  9. 【刷题-LeetCode】304. Range Sum Query 2D - Immutable

    Range Sum Query 2D - Immutable Given a 2D matrix matrix, find the sum of the elements inside the rec ...

  10. opencv 4.0 + linux + cuda静态编译

    #下载最新的opencv git clone "https://github.com/opencv/opencv.git" git clone "https://gith ...