以UIButton为例,创建一个类,继承于UIButton

/*页面的创建用storyboard*/                                      

.h文件   

@interface PTSRecommendButton : UIButton

- (void)viewTransform;

@end

.m文件

@implementation PTSRecommendButton

- (void)viewTransform {

//

[self.layer setAnchorPoint:CGPointMake(1, 0.5)];

CGRect btnFrame = self.frame;

//设置中心点  AnchorPoint默认是0.5

btnFrame.origin.x += btnFrame.size.width / 2 ;

self.frame = btnFrame;

//放大

[UIView transitionWithView:self duration:0.5 options:UIViewAnimationOptionAllowUserInteraction animations:^{

   //因为是button在动画之行的过程点击如果没有页面跳转的操作。要设置不能狗被点击 否则会引起动画方法的覆盖

//self.userInteractionEnabled = NO;

self.transform = CGAffineTransformMakeScale(1.2, 1.2);

} completion:^(BOOL finished) {

//还原中心点

[self.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

CGRect btnFrame = self.frame;

btnFrame.origin.x -= btnFrame.size.width / 2 ;

self.frame = btnFrame;

//旋转

[UIView transitionWithView:self duration:0.25 options:UIViewAnimationOptionAllowUserInteraction animations:^{

//

self.transform = CGAffineTransformRotate(self.transform, M_PI*0.05);

} completion:^(BOOL finished) {

//反向旋转

[UIView transitionWithView:self duration:0.5 options:UIViewAnimationOptionAllowUserInteraction animations:^{

self.transform = CGAffineTransformRotate(self.transform, -M_PI*0.1);

} completion:^(BOOL finished) {

//回到最初旋转状态

[UIView transitionWithView:self duration:0.25 options:UIViewAnimationOptionAllowUserInteraction animations:^{

self.transform = CGAffineTransformRotate(self.transform, M_PI*0.05);

} completion:^(BOOL finished) {

//中心点还原

[self.layer setAnchorPoint:CGPointMake(1, 0.5)];

CGRect btnFrame = self.frame;

btnFrame.origin.x += btnFrame.size.width / 2 ;

self.frame = btnFrame;

//恢复初始的状态

[UIView transitionWithView:self duration:0.5 options:UIViewAnimationOptionAllowUserInteraction animations:^{

self.transform = CGAffineTransformIdentity;

} completion:^(BOOL finished) {

[self.layer setAnchorPoint:CGPointMake(.5, 0.5)];

CGRect btnFrame = self.frame;

//设置中心点  AnchorPoint默认是0.5

btnFrame.origin.x -= btnFrame.size.width / 2 ;

self.frame = btnFrame;

//self.userInteractionEnabled = YES ;

}];

}];

}];

}];

}];

}

@end

最新文章

  1. LCQCL
  2. android给View设置边框 填充颜色 弧度
  3. Cacti -- Advance Ping
  4. jQueryEasyUI Messager基本使用
  5. 11.3Daily Scrum
  6. Name-based virtual servers 给予名称的虚拟服务
  7. DevExpress学习笔记1-ProductsDemo.Win
  8. HTML5 离线缓存
  9. readn、write、readline
  10. PowerDesigner 对 Oracle 作 逆向工程
  11. div+css位置绝对定位和相对定位
  12. JQuery实现点击关注和取消功能
  13. 用SqlCommandBuilder 实现批量更新
  14. 第三方工具 - 关于echarts下钻功能的一些总结.js
  15. HDU-1171 Big Event in HDU(生成函数/背包dp)
  16. Taro 多端开发的正确姿势:打造三端统一的网易严选(小程序、H5、React Native)
  17. Pycharm启动后加载anaconda一直updating indices造成Pycharm闪退甚至电脑崩溃
  18. C++多态实现原理详解
  19. ubuntu18.04 安装mysql server
  20. js获取本机id

热门文章

  1. Windows Azure Platform Introduction (14) 申请海外的Windows Azure账户
  2. 二维码开源库ZBar-吐槽篇
  3. mdb导入SqlServer
  4. 装x玩法:插上你的专有U盘才能开机
  5. appium滑动操作(向上、向下、向左、向右)
  6. 高可用之KeepAlived(一):基本概念和配置文件分析
  7. Docker第一弹:下载运行hello-world程序
  8. PHP动态编译出现Cannot find autoconf的解决方法
  9. python针对端口11211进行全网收集
  10. Android 如何进行页面传递对象