头尾式动画
来源:互联网 发布:域名访问升级访问 编辑:程序博客网 时间:2024/04/28 20:39
#import "ViewController.h"
@interface ViewController ()
//放大
- (IBAction)big ;
//缩小
- (IBAction)samll ;
//头像
@property(nonatomic,weak)IBOutletUIButton *head;
//移动
- (IBAction)move:(UIButton *)btn;
@end
@implementation ViewController
- (void)big{
// NSLog(@"我看到一个big美女");
// 1.取出对象的结构体属性frame,赋值给临时变量
CGRect tempFrame = self.head.frame;
1.取出对象的结构体属性bounds,赋值给临时变量
CGRect tempBounds = self.head.bounds;
// 2.修改临时变量的值
// tempFrame.origin.y = tempFrame.origin.y - 10;
tempBounds.size.width +=10;
tempBounds.size.height +=10;
tempFrame.size.width +=10;
tempFrame.size.height +=10;
// 3.用临时变量的值覆盖原来的变量
self.head.frame = tempFrame;
NSLog(@"%@",NSStringFromCGRect(self.head.frame));
}
- (void)samll{
// NSLog(@"我看到一个samll美女");
// 1.取出对象的结构体属性frame,赋值给临时变量
CGRect tempFrame = self.head.frame;
// 2.修改临时变量的值
// tempFrame.origin.y = tempFrame.origin.y - 10;
tempFrame.size.width -=10;
tempFrame.size.height -=10;
// 3.用临时变量的值覆盖原来的变量
self.head.frame = tempFrame;
}
//如果用一个方法监听按钮点击,如果传入一个参数,那么会把对应的点击的按钮当成参数传递进来
- (void)move:(UIButton *)btn{
// NSLog(@"%@",NSStringFromCGRect(btn.frame));
// 头尾式动画
NSLog(@"%@",btn);
// 0.开启动画
[UIViewbeginAnimations:nilcontext:nil];
// 0.1设置动画时间
[UIViewsetAnimationDuration:1.0];
// 1.取出对象的结构体属性frame,赋值给临时变量
CGRect tempFrame = self.head.frame;
// 1.取出对象的结构体属性frame,赋值给临时变量
CGPoint tempCenter = self.head.center;
CGFloat dealta = 50;
switch (btn.tag) {
case 10:
//------------------------$------------------------------------
tempCenter.y -= dealta
tempFrame.origin.y -= dealta;
break;
case 20:
tempFrame.origin.y += dealta;
break;
case 30:
tempFrame.origin.x -= dealta;
break;
case 40:
tempFrame.origin.x += dealta;
break;
}
// 3.用临时变量的值覆盖原来的变量
self.head.frame = tempFrame;
// 4.提交动画
[UIViewcommitAnimations];
}
- 头尾式动画
- 头尾式动画
- iOS头尾式动画使用
- OC动画2(头尾式动画)
- 简单的动画头尾式的使用
- 带头尾和动画的下拉刷新RecyclerView
- 头尾指针
- 字符串头尾加上单引号
- 对日邮件头尾格式
- 同头尾合十法
- 去掉字符串头尾空格
- 去除字符串头尾空格
- webview添加头尾视图
- iOS --- UIcollectionView设置头尾
- xListView头尾布局
- [Widget]HeaderFooterGridView-头尾GridView
- 给RecyclerView添加头尾
- 二进制字符串的头尾调转
- Fedora20上Xen的安装与部署
- 如何建设一个高性能网站
- Chrome明文存储密码
- Hidden String(模拟)
- S5PV210开发系列七_Nand驱动实现
- 头尾式动画
- C++ 智能指针的简单实现
- 【Linux C 多线程编程】互斥锁与条件变量
- zoj2481 Unique Ascending Array
- ICMP报文格式详解
- Mac解压命令之不解压__MACOSX相关文件
- CSDN极客头条使用指南
- QT实现一个简单的计算器
- S5PV210开发系列八_Yaffs的移植