//
// 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. Oracle 创建数据表以及对数据表、字段、主外键、约束的操作

    选择主键的原则: 最少性 尽量选择使用单个键作为主键 稳定性 尽量选择数值更新少的列作为主键 1.创建数据表(CREATE TABLE) --创建数据表Student create table Stu ...

  2. gogs安装与说明(docker)

    作为一个开发,少不了和git打交道,像github,gitee是很流行的git线上托管平台,而我们也搭建自己的git托管平台,有条件的可以使用gitlab,它对硬件有要求,像博主这种没条件用虚拟机的, ...

  3. [学习笔记] Oracle运算符、连接符、结果去重、范围查询、模糊查询

    运算符 符号 解释 + 加法 - 减法 * 乘法 / 除法,结果是浮点数 = 等于 > 大于 < 小于 <>或者!= 不等于 >= 大于或者等于 <= 小于或者等于 ...

  4. [学习笔记] RabbitMQ的安装使用

    安装 使用命令行安装,会自动管理依赖(推荐): choco install rabbitmq 安装包安装: 以管理员身份安装64位的 Erlang. 下载并安装 RabbitMQ 服务.下载地址. R ...

  5. JMeter_性能压测报错address already in use:connect

    报错截图如下: 原因分析: 这个问题的原因是windows端口被耗尽了(默认1024-5000),而且操作系统要 2~4分钟才会重新释放这些端口,所以可以增加windows的可用端口来解决.windo ...

  6. 第10组 Alpha冲刺 (4/6)(组长)

    1.1基本情况 ·队名:今晚不睡觉 ·组长博客:https://www.cnblogs.com/cpandbb/p/13982696.html ·作业博客:https://edu.cnblogs.co ...

  7. 自动化集成:Pipeline整合Docker+K8S

    前言:该系列文章,围绕持续集成:Jenkins+Docker+K8S相关组件,实现自动化管理源码编译.打包.镜像构建.部署等操作:本篇文章主要描述流水线集成K8S用法. 一.背景描述 分布式服务的部署 ...

  8. MongoDB-基础知识学习(一)

    概述 最近mongodb在互联网的活跃度直线上升,并且我们公司也使用了mongoDB 3.6 作为生产重要的数据库,我们项目组要监控mongodb的op.log日志,在此整理以前学习的知识,为以后备份 ...

  9. 利用栈实现括号匹配(python语言)

    原理: 右括号总是与最近的左括号匹配 --- 栈的后进先出 从左往右遍历字符串,遇到左括号就入栈,遇到右括号时,就出栈一个元素与其配对 当栈为空时,遇到右括号,则此右括号无与之匹配的左括号 当最终右括 ...

  10. [GKCTF2020]EZ三剑客-EzNode&[GYCTF2020]Ez_Express

    写在前面 Nodejs基础一点没有做题还是很难下手的,要学的还很多 [GKCTF2020]EZ三剑客-EzNode 知识点 1.settimeout溢出 2.沙盒逃逸 题解 打开题目,看源代码 app ...