iOS UI-手势(Gesture)
#import "ViewController.h" @interface ViewController ()<UIActionSheetDelegate>
@property (strong, nonatomic) UITextField *me_textfield; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor lightGrayColor]];
/*
手势分类:
滑动手势、点击手势、双击手势、长按手势等7种
*/ // self.me_textfield = [[UITextField alloc] initWithFrame:CGRectMake(0, 100, 375, 100)];
// self.me_textfield.placeholder = @"请输入";
// self.me_textfield.borderStyle = UITextBorderStyleRoundedRect;
// //self.me_textfield.center =self.view.center;
// [self.view addSubview:self.me_textfield]; //创建点击手势
UITapGestureRecognizer *click = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToDoSomething)];
[self.view addGestureRecognizer:click]; //创建长按手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressToDoSomething)];
longPress.minimumPressDuration = 2.0;
[self.view addGestureRecognizer:longPress]; //创建捏合手势
UIPinchGestureRecognizer *pich = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pichToDoSomething)];
[self.view addGestureRecognizer:pich]; //创建旋转手势
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationToDoSomething)];
[self.view addGestureRecognizer:rotation]; //创建轻扫手势
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToDoSomething)];
[self.view addGestureRecognizer:swipe]; //创建拖动手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panToDoSomething)];
[self.view addGestureRecognizer:pan]; //创建屏幕边缘拖动手势
UIScreenEdgePanGestureRecognizer *screenEdgePan =[[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgePanToDoSomething)];
[self.view addGestureRecognizer:screenEdgePan];
}
#pragma mark - 屏幕边缘拖动手势关联方法
- (void)screenEdgePanToDoSomething
{
NSLog(@"屏幕边缘拖动");
}
#pragma mark - 拖动手势关联方法
- (void)panToDoSomething
{
NSLog(@"拖动");
}
#pragma mark - 轻扫手势关联方法
- (void)swipeToDoSomething
{
NSLog(@"轻扫");
}
#pragma mark - 旋转手势关联方法
- (void)rotationToDoSomething
{
NSLog(@"旋转");
}
#pragma mark - 捏合手势关联方法
- (void)pichToDoSomething
{
NSLog(@"捏合");
}
#pragma mark - 长按手势关联方法
- (void)longPressToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"关机" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show];
}
#pragma mark - 点击手势关联方法
- (void)clickToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"你点我试试" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
iOS UI-手势(Gesture)的更多相关文章
- 点击事件touches与ios的手势UIGestureRecognizer
.h文件 @property (weak,nonatomic) IBOutlet UILabel *messageLabel;@property (weak,nonatomic) IBOutlet U ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- android学习笔记52——手势Gesture,增加手势、识别手势
手势Gesture,增加手势 android除了提供了手势检测之外,还允许应用程序把用户手势(多个持续的触摸事件在屏幕上形成特定的形状)添加到指定文件中,以备以后使用 如果程序需要,当用户下次再次画出 ...
- android学习笔记51——SQLite 手势Gesture
手势Gesture 所谓手势,是指用户手指或触摸笔在触摸屏幕上的连续触碰行为. Androi对两种手势行为都提供了支持: 1.对于第一种手势而言,android提供了手势检测,并为手势检测提供了相应的 ...
- [IOS]IOS UI指南
[IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...
- [BS-25] IOS中手势UIGestureRecognizer概述
IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...
- IOS各种手势操作实例
先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击 UITapGestureRecogniz ...
- 国外IOS UI指南
国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...
- iOS UI的几种模式
iOS UI的几种模式: 1.平凡模式(原生控件组合): 2.新闻模式: 3.播放器模式: 4.微博模式:
- IOS中手势UIGestureRecognizer
通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...
随机推荐
- 02: python3使用email和smtplib库发送邮件
1.1 发送qq邮箱 注:python代理登录qq邮箱发邮件,是需要更改自己qq邮箱设置的.在这里大家需要做两件事情:邮箱开启SMTP功能 .获得授权码 教程链接 1.给单个人发邮件 参考 from ...
- 20145101《Java程序设计》第10周学习总结
20145101<Java程序设计>第10周学习总结 教材学习内容总结 网络编程 网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据传输. 计算机网络 路由器和交换机组成了核心的 ...
- SQLSERVER中order by ,group by ,having where 的先后顺序
SELECT [Name] FROM [LinqToSql].[dbo].[Student] where name='***' group by name having (name='* ...
- HDU1560 DNA sequence(IDA*)题解
DNA sequence Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- [BZOJ1044][HAOI2008]木棍分割 二分 + 单调队列优化dp + 滚动数组优化dp
Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长 ...
- UVa 1025 城市里的间谍
https://vjudge.net/problem/UVA-1025 题意:一个间谍要从第一个车站到第n个车站去会见另一个,在是期间有n个车站,有来回的车站,让你在时间T内时到达n,并且等车时间最短 ...
- EasyUI ---- draggable购物车
@{ ViewBag.Title = "Easyui_draggable"; Layout = "~/Views/Shared/Layouts.cshtml"; ...
- c++ 多继承 public
以下代码会报错 #include <iostream> using namespace std; class Sofa { public: Sofa(); ~Sofa(); void si ...
- c++ 指定长度容器元素的拷贝(copy_n)
#include <iostream> // cout #include <algorithm> // copy #include <vector> ...
- Codeforces 911E - Stack Sorting
911E - Stack Sorting 思路: 用栈来模拟,能pop就pop,记下一个需要pop的数为temp,那么如果栈非空,栈顶肯定大于temp,那么加入栈 栈顶值-1 到 temp 的值,否则 ...