简体   繁体   English

iPhone如何在相机应用程序中获得照片拍摄效果?

[英]iPhone How to get photo taken effect like in camera application?

I am talking about that effect when user presses button to take photo, it shrinks and moves to toolbar? 我说的是这种效果,当用户按下按钮拍照时,它会缩小并移至工具栏吗? How is this achieved in general? 一般如何实现?

so the shrink animation is achived by 所以收缩动画是通过

 [UIView beginAnimations:@"animationShrink" context:NULL];
    [UIView setAnimationDuration:kSlideInAnimationDuration];

    flipFlopContainer.transform = CGAffineTransformMakeScale(0.01, 0.01);
    [UIView setAnimationDelegate:self];
    [UIView    setAnimationDidStopSelector:@selector(shrinkAnimationFinished:)];
    [UIView commitAnimations];

after this animation in shrinkAnimationFinished method you need to define a path to follow and change the position of your view accroding to that path. 在使用rinkenAnimationFinished方法制作此动画之后,您需要定义一条要遵循的路径,并更改视图对该视图的位置。

See the following thread for that animation 参见以下有关该动画的主题

Resize and move a UIView with Core Animation (CAKeyFrameAnimation) 使用核心动画(CAKeyFrameAnimation)调整大小和移动UIView

You can create this by both scaling (applying a transform) and moving (animating the position) of the image. 您可以通过缩放(应用变换)和移动(动画位置)图像来创建图像。

I wrote about a similar animation (the Open in Background animation from Safari on iPhone) in this blog post . 我在此博客文章中写了一个类似的动画(iPhone上的Safari中的“在后台打开动画”)。 Not all of the code is necessary but some part of it will be useful for the animation you are trying to do. 并非所有代码都是必需的,但是其中的一部分对您尝试制作的动画很有用。


You should 你应该

  • Calculate the scale factor to make the image the appropriate size 计算比例因子以使图像适当大小
  • Calculate the path you want to animate the image along. 计算您要为图像设置动画的路径。
  • Animate a scale with the calculated scale factor 使用计算出的比例因子对比例进行动画处理
  • Animate a position animation along the path (using a CAKeyframeAnimation) 沿路径对位置动画进行动画处理(使用CAKeyframeAnimation)

Since you are doing two animations at once you could benefit from using a CAAnimationGroup. 由于您一次要制作两个动画,因此可以受益于使用CAAnimationGroup。

Since you are animating down to a toolbar which probably is another part of the view hierarchy than where the image is you may need to use method like 由于您正在动画化一个工具栏,该工具栏可能是视图层次结构的一部分,而不是图像所在的位置,因此您可能需要使用类似

- (CGRect)convertRect:(CGRect)rect toView:(UIView *)view

and

- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view 

To translate coordinates between the different views. 在不同视图之间转换坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测照片库中的图像是由iPhone相机拍摄还是导入 - how to detect if image from photo library was taken by iPhone camera or imported iPhone SDK-如何在UINavigationController中显示用相机拍摄的照片? - iPhone SDK - How to display a photo taken with the camera inside a UINavigationController? 在iPad或iPhone相机中拍摄的照片的DPI是多少? - What is DPIs of photo taken in iPad or iPhone camera? iPhone 4相机拍摄的照片分辨率是多少? - what is resolution of photo taken by iPhone 4 camera? iPhone:如何通过iPhone照片应用程序等“编辑”功能从照片库或相机中获取图像 - iPhone:How to fetch image from photo library or camera with “edit” funcitionality like iPhone photo app 从iPhone中的相机拍摄时,将视频保存到照片库 - Saving videos to photo library when taken from camera in IPhone 如何在MacBook Pro上获得Photo Booth Flash Effect - How to get Photo Booth Flash Effect like on MacBook Pro 如何在iPhone中创建类似于Photo应用程序的界面? - How to create similar interface like the Photo application in iPhone? 如何检测iPhone相机没有拍摄UIImage? - How to detect wether an UIImage was not taken by the iPhone camera? 获取从相机/照片库拍摄的图像的名称 - Get the name of an image taken from camera/photo library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM