首页 > 代码库 > Core Animation 学习笔记(一)

Core Animation 学习笔记(一)

看到网易贴吧的点赞的动画,模仿做了个差不多的效果
-(void)zanAction
{
    UILabel *oneLbl =[[UILabel alloc]init];
    oneLbl.frame = CGRectMake(_zanBtn.frame.origin.x, _zanBtn.frame.origin.y, 35, 20);
    oneLbl.text =@"+1";
    oneLbl.font = [UIFont boldSystemFontOfSize:17.0];
    oneLbl.textColor = [UIColor colorWithRed:236/255.0 green:93/255.0 blue:114/255.0 alpha:0.8];
    
    CGRect rect =_zanBtn.frame;
    [_zanBtn setImage:[UIImage imageNamed:@"praised.png"] forState:UIControlStateNormal];
    
    [UIView animateWithDuration:0.2+3
                          delay:0
                        options:0 animations:^{
                            _zanBtn.frame = CGRectMake(_zanBtn.frame.origin.x, _zanBtn.frame.origin.y, _zanBtn.frame.size.width*1.2, _zanBtn.frame.size.height*1.2);
                            
                        } completion:^(BOOL finished){
                            _zanBtn.frame =rect;
                            [UIView animateWithDuration:0.8+3
                                                  delay:0
                                                options:0 animations:^{
                                                    [self.view addSubview:oneLbl];
                                                    //上、右移动10px  增大到1.2倍
                                                    oneLbl.frame = CGRectMake(oneLbl.frame.origin.x , oneLbl.frame.origin.y-25, oneLbl.frame.size.width*1.4, oneLbl.frame.size.height*1.4);
                                                    oneLbl.alpha = 0;
                                                } completion:^(BOOL finished){
                                                    [oneLbl removeFromSuperview];
                                                    
                                                }];
                             }] ;
                            
}

Core Animation 学习笔记(一)