2

当您在我的 iOS 应用程序中双击图片时,我想实现 Instagram 使用的“点赞”动画。这是一个非常漂亮的功能,并且认为它会为我的应用程序增添一点味道。我发布了双击前后的照片。心脏在大约两秒钟内淡入淡出。我想不明白。让我知道!

前

后

4

3 回答 3

0

好吧,如果你想使用动画方法,你可以使用帧序列来做到这一点。

Toast(就像在 android 中一样)方法也是完美的,为此您可以在此处查看适用于 iOS 的重复问题 Growl/toast 样式通知库

于 2012-09-11T05:32:05.070 回答
0
#define LIKED 100 //change as per your requirement
#define UNLIKE 200 //change as per your requirement

- (void) likeUnlike:(UIGestureRecognizer *)sender
{
    [imageViewSub setHidden:NO];

    UIImageView *imageView = (UIImageView *)sender.view;

    if(imageView.tag==LIKED)
    {
        [imageViewSub setImage:[UIImage imageNamed:@"unlike.png"]];
        [imageView setTag:UNLIKE];
    }
    else
    {
        [imageViewSub setImage:[UIImage imageNamed:@"like.png"]];
        [imageView setTag:LIKED];
    }

    //here, your like/unlike update call to server for store selection.

    //set the frame exactly you want or
    //implement some other way to hide `imageViewSub` after like/unlike
    [imageViewSub setFrame:CGRectMake( 110, 180, 100, 100)];
    [UIView beginAnimations:@"anim" context:nil];
    [UIView setAnimationDuration:1.0];
    [imageViewSub setFrame:CGRectMake(200, 200, 0, 0)]; 
    [UIView commitAnimations];
}

//Add below code where you're added/showing your images. There's always two `UIImageView`s one is `main` and other one is `sub`.

[imageViewSub bringSubviewToFront:imageViewMain];

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] init];
[doubleTap setNumberOfTapsRequired:2];
[doubleTap addTarget:self action:@selector(likeUnlike:)];
[imageViewMain addGestureRecognizer:doubleTap];
[doubleTap release];

PSimageViewMain最初会带有标签,并且UNLIKED应该被隐藏。imageViewSubunlike.png

于 2012-09-11T06:11:12.680 回答
0

在我的一些项目中,我一直在使用MBProgressHUD。您可以设置标准图像/进度圈,或自定义图像,还可以自定义标签的字体。我很喜欢。如果您将它与 performBlockAfterDelay 一起使用(选中此类别),它可以为您节省大量时间,让您的生活更轻松。

于 2012-09-11T06:24:38.577 回答