【问题标题】:How to add Instagram model 'like' animation? [closed]如何添加 Instagram 模型“喜欢”动画? [关闭]
【发布时间】:2014-02-10 11:24:55
【问题描述】:

我正在尝试开发一个显示图像提要的 iphone 应用程序。在应用程序中有喜欢和不喜欢的功能。我需要类似 Instagram 的效果。

喜欢和不喜欢有不同的图像..

我对如何做到这一点感到困惑。所以我没有做任何编码。

有没有示例代码,库可用?

谢谢..

【问题讨论】:

  • 得到了视频或图片,因为我不使用 Instagram,所以不知道您指的是什么,因此无法为您提供解决方案
  • 您只是想在单击时更改按钮的图像吗?

标签: ios iphone instagram


【解决方案1】:

在你的 -(void)viewDidLoad

UITapGestureRecognizer *oneFingerTwoTaps = 
      [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerTwoTaps)] autorelease];

    // Set required taps and number of touches
    [oneFingerTwoTaps setNumberOfTapsRequired:2];
    [oneFingerTwoTaps setNumberOfTouchesRequired:1];

    // Add the gesture to the view/UIImageView
    [[self view] addGestureRecognizer:oneFingerTwoTaps];

使用你的 UIImageView 代替 [self view]。

在下一步中,您将创建双击图像的动作

- (void)oneFingerTwoTaps
{
  // Action for Fade In the "Heart"
  UIImage *image = [UIImage imageNamed:@"yourlikeimageoverlay.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];


//Add the image view to your main view
//(This is optional if it was created with Interface Builder)
...


CABasicAnimation *theAnimation;

//within the animation we will adjust the "opacity"
//value of the layer
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
//animation lasts 0.4 seconds
theAnimation.duration=0.4;
//and it repeats forever
theAnimation.repeatCount= 1e100f;
//we want a reverse animation
theAnimation.autoreverses=YES;
//justify the opacity as you like (1=fully visible, 0=unvisible)
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.1];

//Assign the animation to your UIImage layer and the
//animation will start immediately
[imageView.layer addAnimation:theAnimation
                 forKey:@"animateOpacity"];
}

【讨论】:

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