ios22--动画
2024-09-25 15:57:47
控制器:
//
// ViewController.m
// 07-渐变动画
//
// Created by xiaomage on 15/12/30.
// Copyright © 2015年 小码哥. All rights reserved.
// #import "ViewController.h" @interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *animationView; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
} /**
* 平移
*/
- (IBAction)translate {
// 渐变动画
// 方式一
/*
// 1. 开始动画
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0]; // 2.动画代码
CGRect frame = self.animationView.frame;
frame.origin.y -= 50;
self.animationView.frame = frame; // 3.提交动画
[UIView commitAnimations];
*/ // 方式二:
/*
[UIView animateWithDuration:2.0 animations:^{
// 1.动画代码
CGRect frame = self.animationView.frame;
frame.origin.y -= 50;
self.animationView.frame = frame;
}];
*/ /*
[UIView animateWithDuration:1.0 animations:^{
// 执行动画
CGRect frame = self.animationView.frame;
frame.origin.y -= 50;
self.animationView.frame = frame;
} completion:^(BOOL finished) {
// 动画完成做什么事情
self.animationView.backgroundColor = [UIColor blackColor];
}];
*/
/*
UIViewAnimationOptionCurveEaseInOut 动画开始/结束比较缓慢,中间相对较快
UIViewAnimationOptionCurveEaseIn 动画开始比较缓慢
UIViewAnimationOptionCurveEaseOut 动画结束比较缓慢
UIViewAnimationOptionCurveLinear 线性---> 匀速
*/
[UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ CGRect frame = self.animationView.frame;
frame.origin.y += ;
self.animationView.frame = frame; } completion:^(BOOL finished) {
self.animationView.backgroundColor = [UIColor greenColor];
}];
} /**
* 缩放
*/
- (IBAction)scale { [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseIn animations:^{ CGRect frame = self.animationView.frame;
frame.size = CGSizeMake(, );
self.animationView.frame = frame; } completion:^(BOOL finished) {
NSLog(@"动画完成");
}];
} /**
* 透明度动画
*/
- (IBAction)alpha {
[UIView animateWithDuration:1.0 delay:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.animationView.alpha -= 0.9;
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 animations:^{
self.animationView.alpha += 0.9;
}];
}];
}
@end
最新文章
- jquery ajax异步和同步从后天取值
- 并查集(union-find)算法
- 浏览器 的 session 如何保持?!
- POJ 2376 Cleaning Shifts 贪心
- Matlab中min/max函数的误解
- for嵌套for ★
- WindowsServer2012 取消密码策略
- 踩坑学php(1)
- Hystrix 使用与分析
- Cocos2d-x 3.1.1 学习日志16--A星算法(A*搜索算法)学问
- 深入理解 Android 消息机制原理
- php 将pdf转成图片且将图片拼接
- CTF---安全杂项入门第二题 A记录
- three.js 实现全景以及优化(2)
- ubuntu上安装multi-mechanize步骤
- Java开发笔记(三十六)字符串的常用方法
- 【Spark-SQL学习之二】 SparkSQL DataFrame创建和储存
- 在Ajax返回多个值
- linux日常运维常用命令
- 【LOJ】#2496. 「AHOI / HNOI2018」毒瘤
热门文章
- <;Redis>; 入门五 持久化RBD/AOF
- 使用ajax解析后台json数据时:Unexpected token o in JSON at position 1
- mysql主库与从库配置(并行复制配置)
- 微信小程序 video组件 不随页面滚动
- 79-Envelopes,包络指标.(2015.7.1)
- 解决Antimalware Service Executable CPU,内存占用高的问题
- IDEA的Maven Projects无法显示
- 【03】AJAX 向服务器发送请求
- api安全认证
- 关于OPENSSL的EVP函数的使用