ios开发 点击文本(TextField)输入的时候向上推以及输入之后恢复的动画
1.添加委托UITextFieldDelegate
2.
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
} //隐藏键盘
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[self animateTextField: textField up: YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
[self animateTextField: textField up: NO];
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up {
const int movementDistance = ; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed int movement = (up ? -movementDistance : movementDistance); [UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, , movement);
[UIView commitAnimations];
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil]; #pragma mark - 键盘处理
#pragma mark 键盘即将显示 - (void)keyBoardWillShow:(NSNotification *)note{ CGRect rect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat ty = - rect.size.height;
[UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
self.view.transform = CGAffineTransformMakeTranslation(, ty + kNavigationBarHeight);
}]; } #pragma mark 键盘即将退出 - (void)keyBoardWillHide:(NSNotification *)note{ [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
self.view.transform = CGAffineTransformIdentity;
}];
}
ios开发 点击文本(TextField)输入的时候向上推以及输入之后恢复的动画的更多相关文章
- IOS开发UI基础文本属性Attributes
文本属性Attributes 1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFo ...
- iOS开发中获取文本的宽高的方式
/** 计算单行文字的size @parms 文本 @parms 字体 @return 字体的CGSize */ + (CGSize)sizeWithText:(NSString *)text ...
- iOS开发——点击图片全屏显示
点击图片,全屏显示,然后再点击屏幕一下,返回. 没啥难的,直接上代码: // // ViewController.m // Demo-hehe // // Created by yyt on 1 ...
- iOS开发进阶 - 富文本正则替换表情
移动端访问不佳,请访问我的个人博客 最近写项目需要用到富文本解析字符串显示表情,下面是我使用正则替换实现富文本的方式,希望能帮助到大家 先上效果图和demo地址 实现过程中需要用到的知识点 NSReg ...
- iOS开发 点击某处横屏竖屏切换
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDe ...
- iOS开发 点击跳转到App Store 或者 点击按钮去评价
//跳转到应用页面 NSString *str = [NSString stringWithFormat:@"http://itunes.apple.com/us/app/id%d" ...
- iOS:iOS开发非常全的三方库、插件等等
iOS开发非常全的三方库.插件等等 github排名:https://github.com/trending, github搜索:https://github.com/search. 此文章转自git ...
- iOS开发之资料收集
github排名:https://github.com/trending, github搜索:https://github.com/search. 此文章转自github:https://github ...
- iOS开发 非常全的三方库、插件、大牛博客等等
UI 下拉刷新 EGOTableViewPullRefresh- 最早的下拉刷新控件. SVPullToRefresh- 下拉刷新控件. MJRefresh- 仅需一行代码就可以为UITableVie ...
随机推荐
- DataGridView使用技巧二:设置单元格只读
一.修改ReadOnly属性 1.设置整个DataGridView只读: DataGridView.ReadOnly=true; 此时用户的新增行和删除行操作也被屏蔽了. 2.设置DataGridVi ...
- spring boot 自学笔记(四) Redis集成—Jedis
上一篇笔记Reddis集成,操作Redis使用的是RedisTemplate,但实际中还是有一大部分人习惯使用JedisPool和Jedis来操作Redis, 下面使用Jedis集成示例. 修改Red ...
- 用 phpize 编译共享 PECL 扩展库
有时候不能用 pecl 安装命令.这可能是因为在防火墙后面,或者是因为想要安装的扩展库还没有 PECL 兼容的包,例如 SVN 中尚未发布的扩展库.如果要编译这种扩展库,可以用更底层的编译工具来手工进 ...
- 'cl.exe' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
1.首先找到vcvars32.bat文件,一般在C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin文件夹下 2.打开cmd黑窗 ...
- 修改ES分片规则
转自:http://my.oschina.net/crxy/blog/422287?p=1 Es查询的时候默认是随机从一些分片中查询数据,可以通过配置让es从某些分片中查询数据 1:_local 指查 ...
- 【转】DWM 窗体玻璃效果实现
我一直盼望着 Windows 新版本的发布.令人感兴趣的事情莫过于浏览 MSDN® 和 SDK 文档,查找一些可以利用和依赖的最新创新,然后让朋友和同事以及您的老板(如果幸运的话)大开眼界.Windo ...
- e553. 作为浏览器访问URL
// See also e551 精简的Applet try { URL url = new URL(getDocumentBase(), "http://hostname.com/page ...
- Sublime Text 3安装清爽主题(著名的Soda Theme)
Sublime Text是一款强大的编辑器,不但拥有众多强大的功能,还拥有很多漂亮的主题以及大量的插件可供配置使用. 本文主要描述Sublime Text 3安装清爽的主题,默认的深色主题Monoka ...
- Linux(Ubuntu)下搭建ASP.NET Core环境
今天来学习一下ASP.NET Core 运行在Ubuntu中.无需安装mono . 环境 Ubuntu 14.04.4 LTS 服务器版 全新安装系统. 下载地址:http://mirrors.neu ...
- u3d调用c++ dll的DllNotFoundExceion 问题
原文地址:http://blog.csdn.net/boren31/article/details/8778504 问题年年有,今年特别多. 开发环境: Windows XP sp3 Visual ...