feat: 初始化

This commit is contained in:
杭城小刘
2018-09-11 10:11:39 +08:00
committed by 杭城小刘
commit 8e5d2c9e7f
264 changed files with 12082 additions and 0 deletions

65
第一部分 iOS/1.29.md Normal file
View File

@@ -0,0 +1,65 @@
# 仿微博弹簧动画
> 老玩微博,最近在研究动画,周末抽空写了个发微博的动画
# 实现步骤
- 首先模打出一个控制器
- 这个控制器用来显示多个按钮。(按钮是图文上下排列的,所以我们需要自定义按钮的布局样式)
- 动画思路:先在界面添加好几个 UIButton之后给每个 button 添加**y**方向的平移动画 -> 设置一个定时器,每次执行的时候依次取出按钮,将按钮添加一个弹簧动画(**usingSpringWithDamping **)将形变动画恢复原位
- 给按钮添加2种事件按下的事件、点击后抬起的事件
## 关键代码
```
//开始时让所有按钮都移动到最底部
btn.transform = CGAffineTransformMakeTranslation(0, self.view.bounds.size.height);
//添加定时器
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(update) userInfo:nil repeats:YES];
- (void)update{
if (self.btnIndex == self.btnArray.count) {
[self.timer invalidate];
return ;
}
VerticalStyleButton *button = self.btnArray[self.btnIndex];
//弹簧动画
[UIView animateWithDuration:0.3 delay:0.2 usingSpringWithDamping:0.8 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
button.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
}];
self.btnIndex++;
}
- (void)btnClick:(UIButton *)button{
[UIView animateWithDuration:0.25 animations:^{
button.transform = CGAffineTransformMakeScale(1.2, 1.2);
}];
}
- (void)btnClick1:(UIButton *)button{
[UIView animateWithDuration:0.25 animations:^{
button.alpha = 0;
button.transform = CGAffineTransformMakeScale(2, 2);
}];
}
```
# 效果图
![发微博动画效果](https://fantasticlbp.gitbooks.io/knowledge-kit/content/assets/QQ20180610-225937-HD.gif)
[源码地址](https://github.com/FantasticLBP/BlogDemos/tree/master/微博发帖动画)