微博弹性按钮
//微博弹性动画
- (void)moveInAnimation{
UIView *centerV = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 300, 100)];
[self.view addSubview:centerV];
for (int i = 0; i < 6; i ++) {
CGFloat x = (i % 3) * 300 / 3.0;
CGFloat y = (i / 3) * 100 / 2.0 ;
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(x,y, 80, 30)];
[btn setTitle:[NSString stringWithFormat:@"按钮%d",i] forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.visableArray addObject:btn];
[centerV addSubview:btn];
}
[self moveInAnimation];
[self.visableArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
UIButton * btn = obj;
CGFloat x = btn.frame.origin.x;
CGFloat y = btn.frame.origin.y;
CGFloat width = btn.frame.size.width;
CGFloat height = btn.frame.size.height;
btn.frame = CGRectMake(x, [UIScreen mainScreen].bounds.size.height + y - 200 , width, height);
btn.alpha = 0.0;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(idx * 0.03 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.95 delay:0 usingSpringWithDamping:2.85 initialSpringVelocity:25 options:UIViewAnimationOptionCurveEaseIn animations:^{
btn.alpha = 1;
btn.frame = CGRectMake(x, y, width, height);
} completion:^(BOOL finished) {
if ([btn isEqual:[self.visableArray lastObject]]) {
// self.superview.superview.userInteractionEnabled = YES;
}
}];
});
}];
}