【问题标题】:Instagram "like" animation iOSInstagram“喜欢”动画iOS
【发布时间】:2012-09-03 23:54:38
【问题描述】:

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

【问题讨论】:

标签: iphone ios xcode ios5


【解决方案1】:

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

Toast(就像在 android 中一样)方法也很完美,为此您可以在此处查看重复的问题 Growl/toast style notifications library for iOS。

【讨论】:

    【解决方案2】:
    #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];
    

    附: imageViewMain 最初将具有来自 UNLIKED 和 imageViewSub 的标签,具有 unlike.png 并且应该被隐藏。

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-16
        相关资源
        最近更新 更多