动画的button(按下时缩小,松开时恢复)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; self.window.rootViewController = [[RootViewController alloc] init]; [self.window makeKeyAndVisible];
return YES;
} @end
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
#import "RootViewController.h"
@interface RootViewController ()
{
CGFloat buttonScale;//比例
}
@end @implementation RootViewController - (void)viewDidLoad {
[super viewDidLoad];
//初始化button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
buttonScale = 1.0;
button.frame = CGRectMake(, , , );
[button setTitle:@"按钮" forState:];
[button setBackgroundImage:[UIImage imageNamed:@"button"] forState:];
[button addTarget:self action:@selector(buttonDownAction:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
[self.view addSubview:button];
}
/**
* 按钮按下时,执行的方法
*/
- (void)buttonDownAction:(UIButton*)sender{
CGFloat scale = buttonScale < 1.0 ? 1.0 : 0.9;
//变小
[UIView animateWithDuration:0.25 animations:^{
sender.transform = CGAffineTransformMakeScale(scale, scale);
}];
NSLog(@"变小");
}
/**
* 松开按钮时,执行的方法
*/
- (void)buttonAction:(UIButton*)sender{
//恢复原来的尺寸
[UIView animateWithDuration:0.25 animations:^{
sender.transform = CGAffineTransformMakeScale(1.0, 1.0);
} completion:^(BOOL finished) {
//在此执行相应操作
NSLog(@"恢复");
}];
} @end
动画的button(按下时缩小,松开时恢复)的更多相关文章
- 仿饿了么增加购物车旋转控件 - 自带闪转腾挪动画 的button
本篇文章已授权微信公众号 guolin_blog (郭霖)独家公布 转载请标明出处: http://blog.csdn.net/zxt0601/article/details/54235736 本文出 ...
- Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果)
Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果) 首句依然是那句老话,你懂得! finddreams :(http://blog.csdn.net/finddr ...
- onkeyup 事件会在键盘按键被松开时发生
定义和用法 onkeyup 事件会在键盘按键被松开时发生. 语法 onkeyup="SomeJavaScriptCode" 参数 描述 SomeJavaScriptCode 必需. ...
- [Android]Button按下后修改背景图
Button按下后修改背景图 错误做法:为Button添加OnTouch事件监听,根据ACTION_UP和ACTION_DOWN动作来修改Button的背景图 错误原因:从理论上讲,按钮按下修改背景色 ...
- keyup([[data],fn]) 当按钮被松开时,发生 keyup 事件。它发生在当前获得焦点的元素上。
keyup([[data],fn]) 概述 当按钮被松开时,发生 keyup 事件.它发生在当前获得焦点的元素上. 注释:如果在文档元素上进行设置,则无论元素是否获得焦点,该事件都会发生.直线电机选型 ...
- 同时屏蔽ios和android下点击元素时出现的阴影
在ios4+和android2+系统,当手指触摸屏幕a标签链接或按钮时,会产生不同的效果,对于ios点击元素的时候,就会出现一个半透明的灰色背景:对于android则出现红色的边框.对这2个系统自带的 ...
- 【Bootstrap3.0建站笔记二】button可下拉弹出层
1.button可下拉弹出层: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hpbmFwbGFu/font/5a6L5L2T/fontsize/400 ...
- rsync+inotify 实现资源服务器的同步目录下的文件变化时,备份服务器的同步目录更新,以资源服务器为准,去同步其他客户端
测试环境: 资源服务器(主服务器):192.168.200.95 备份服务器(客户端):192.168.200.89 同步目录:/etc/test 同步时使用的用户名hadoop密码12345 实验目 ...
- 清除在Windows下访问共享文件夹时的登录信息
清除在Windows下访问共享文件夹时的登录信息 在实际工作中,经常需要访问局域网内其他机子上的共享文件夹,例如\\192.168.1.100\d$ , 首次访问时,需要输入用户名和密码才可以进入,即 ...
- 在 root 下执行 Oracle 程序时找不到 libclntsh.so.11.1 错误的解决办法。
在 root 下执行 Oracle 程序时找不到 libclntsh.so.11.1 错误的解决办法. 先确定 libclntsh.so.11.1 所在目录: [oracle@localhost ~] ...
随机推荐
- Sql Server 常用方法、存储过程备用
常用方法 --字符串转换成数字 --CAST("1" AS int) --CONVERT(int,"1") --截取字符串 SUBSTRING(OccurreA ...
- c3p0配置 initialPoolSize 和minPoolSize 可以设为0吗?设0有坏处吗?
c3p0配置 initialPoolSize 和minPoolSize 可以设为0吗?设0有坏处吗? c3p0配置 initialPoolSize 和minPoolSize 可以设为0吗?设0有坏处吗 ...
- VR制作的规格分析
因为UE4的演示资源更丰富一些,我这边把UE4的有代表性的演示都跑了一遍,同时也通过Rift确认效果,和里面的资源制作方式. 首先,UE4是基于物理渲染的引擎,大部分都是偏向图像真实的.使用的材质 ...
- spotlight监控工具使用
利用spotlight工具可以监控如下系统: 1.Spotlight on Unix 监控Linux服务器 1)安装 Spotlight on Unix 2)配置spotlight登陆用 ...
- PHP中数组合并的两种方法及区别介绍
PHP数组合并两种方法及区别 如果是关联数组,如下: 复制代码代码如下: $a = array( 'where' => 'uid=1', 'order' => 'uid', ); $b = ...
- Introduction to Structured Data
https://developers.google.com/search/docs/guides/intro-structured-data Structured data refers to kin ...
- JS中基本window.document对象操作以及常用事件!
一.找到元素 1.document.getELementById("id"):根据id找,最多找一个. var a=document.getELementById("id ...
- ADS报错 Warning : L6301W:Could not find file C:\Program Files . Error : L6218 : Undefined symbol ......
ADS1.2编译时,出现找不到一个不存在目录下的目标文件(*.o) 编译一个COPY到硬盘上的一个工程,出现以下的fatal error message: Error: (Fatal)L6002: C ...
- (转)CAS (4) —— CAS浏览器SSO访问顺序图详解(CAS Web Flow Diagram by Example)
CAS (4) —— CAS浏览器SSO访问顺序图详解(CAS Web Flow Diagram by Example) tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0 ...
- UIView 的粗浅解析
The UIView class defines a rectangular area on the screen and the interfaces for managing the conten ...