iOS之UITextField输入错误的震动动画
2024-10-20 07:52:07
//左右震动效果
- (void)shake:(UIView *)view {
CGRect frame = view.frame;
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; CGMutablePathRef shakePath = CGPathCreateMutable();
CGPathMoveToPoint(shakePath, NULL, frame.origin.x+frame.size.width/, frame.origin.y+frame.size.height/);
int index;
for (index = ; index >=; --index) {
CGPathAddLineToPoint(shakePath, NULL, frame.origin.x+frame.size.width/ - frame.size.width * 0.02f * index, frame.origin.y+frame.size.height/);
CGPathAddLineToPoint(shakePath, NULL, frame.origin.x+frame.size.width/ + frame.size.width * 0.02f * index, frame.origin.y+frame.size.height/);
}
CGPathCloseSubpath(shakePath); shakeAnimation.path = shakePath;
shakeAnimation.duration = 0.5f;
shakeAnimation.removedOnCompletion = YES; [view.layer addAnimation:shakeAnimation forKey:nil];
CFRelease(shakePath);
}
最新文章
- hdu 5587 Array
- C#中标准Dispose模式的实现与使用(条目17 实现标准的销毁模式)
- CentOS6.5安装iftop
- 安装360后,visual studio 经常报各种莫名其妙的错误的解决方案
- ThinkPHP中连接mysql数据库的四种实用和通用的连接方法
- leetcode21
- 产品 vs 服务,见识,耐心
- vue 前端框架 (三)
- java新知识系列 三
- 系统环境变量(就是不需要切换目录,敲击“python”就可以进入编码器)
- php const常量 不能使用字符串连接符.链接
- Python requests代理
- 廉价的SUP掌机拆解
- MongoDB--连接客户端和服务
- [题目] Luogu P3716 [CTSC2000]冰原探险
- NLP自然语言处理系列5-支持向量机(SVM)
- libnids使用举例
- c++ STL map 结构体
- win10 uwp 让焦点在点击在页面空白处时回到textbox中
- 【bzoj3926】 Zjoi2015—诸神眷顾的幻想乡