码迷,mamicode.com
首页 > 其他好文 > 详细

微博弹性按钮

时间:2015-12-14 19:02:05      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

//微博弹性动画

- (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;

                }

            }];

        });

        

 

    }];

}

微博弹性按钮

标签:

原文地址:http://www.cnblogs.com/sgdkg/p/5045870.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!