173,动画方法
来源:互联网 发布:sql server decimal 编辑:程序博客网 时间:2024/06/11 22:20
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIButton *btn = [[UIButtonalloc]initWithFrame:CGRectMake(20,20,100, 50)];
btn.backgroundColor = [UIColorgrayColor];
[btn setTitle:@"显示弹框"forState:UIControlStateNormal];
[btn setTitleColor:[UIColorredColor]forState:UIControlStateNormal];
[btn addTarget:selfaction:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:btn];
}
-(void)click:(UIButton *)button{
/**
* 只要修改对象的属性,就可以使用动画方法实现动画 —— frame,bounds,alpha
*第一种动画方法:首尾式动画
*/
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:1];
/**
* 此处放属性变化代码!
*/
[UIViewcommitAnimations];
UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(100,150,100, 40)];
label.text = @"下载成功!";
/**
* colorWithWhite为0,就是黑色,而为1,就是白色,alpha为透明度
*/
label.backgroundColor = [UIColorcolorWithWhite:0alpha:0.1];
label.textAlignment =NSTextAlignmentCenter;
label.textColor = [UIColorredColor];
[self.viewaddSubview:label];
/**
*第二种动画方法:该种方法最为常用,建议使用
*/
label.alpha = 0;
[UIViewanimateWithDuration:1animations:^{
label.alpha = 1;
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:1animations:^{
label.alpha = 0;
} completion:^(BOOL finished) {
//将控件从storyboard中移除
[label removeFromSuperview];
}];
}];
}
@end
- 173,动画方法
- [cocos2d] 调用动画方法
- jQuery 动画 - animate() 方法
- 动画的方法
- 延时动画方法
- 3动画方法
- swift:旋转动画方法
- jQuery动画方法总结
- jQuery动画方法
- Delphi 2009 gif动画方法
- android之动画常用方法
- 页面跳转动画设置方法
- cocos2d-x 动作动画方法
- Android 动画AlphaAnimation类方法
- Android ListView动画实现方法
- ios添加动画的方法
- Unity3D 动画回调方法
- Android 动画AlphaAnimation类方法
- 远程DLL注入、卸载
- DELPHI调用JAVA WEBSERVICE方法 出现 null object 异常的原因
- 119_素数算法之 埃氏筛
- myeclipse启用/关闭debug模式
- 关于使用BeanUtils.copyProperties拷贝时,时间类型为空时转换异常
- 173,动画方法
- myeclipse和eclipse的区别
- sbt编译spark源码
- 《计算机程序的构造与解释》习题自编代码(第1章)(未完待更)
- pip管理的安装与使用——python包的安装
- 存储过程比较两个标的数据 优化
- Eclipse dubbo Multiple annotations found at this line(出错)
- jmeter学习 一
- [Android实例] 仿微信通讯录,A~Z拼音侧边检索