ios - 如何添加 Instagram 模型 'like' 动画?

标签 ios iphone instagram

<分区>

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

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

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

是否有可用的示例代码、库?

谢谢..

最佳答案

在你的 -(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]。

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

- (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"];
}

关于ios - 如何添加 Instagram 模型 'like' 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21675870/

相关文章:

ios - Swift:观察 NSUserDefaults 时出现 EXC_BAD_ACCESS

ios - 将项目引用添加到 Swift iOS XCode 项目并调试

ios - FsCalendar 实现 iOS 中的问题

jquery - XMLHttpRequest 无法像 Instagram 一样加载

iOS - 这个 UIPageViewController 是由 UISegmentedControl 控制的,还是什么?

ios - RxCocoa - 为什么 PublishRelay 没有 asDriver() 方法?

ios - 是否可以在共享扩展中打开完整 View Controller ,而不是弹出窗口(默认)

iphone - iPhone 上的 OpenAL 音调生成

android - 在 Android 上将视频和贴纸图片分享到 Instagram Story

ios - 在为另一个节点使用灯光后保持原始节点照明