Vertigo 0.1

Vertigo 0.1

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布时间最新发布2014年12月

Guille Gonzalez维护。




  • 作者:
  • Guillermo Gonzalez

Vertigo 是一个简单的图片查看器,它包含一个 自定义视图控制器过渡,该过渡模仿了新的 iOS 7 相册应用 图片缩放过渡效果。

Image zoom transition

安装

手动安装

Vertigo 文件夹拖动到您的项目中。如果您的项目不使用 ARC,您必须在 Vertigo 文件夹下的所有 .m 文件中启用它。

使用方法

Vertigo 包含以下类

  • TGRImageViewController 是图片查看器本身。用户可以双击图片来放大或缩小它。单击一次将关闭查看器。
  • TGRImageZoomAnimationController 是执行视图控制器和 TGRImageViewController (即 相册应用 的图片缩放过渡效果)之间自定义过渡的对象。

为了使用自定义过渡效果从您的视图控制器中显示和关闭 TGRImageViewController,您的视图控制器需要实现新的 UIViewControllerTransitioningDelegate 协议,并返回一个用将用作过渡的初始(或关闭时的最终)点的图像视图初始化的 TGRImageZoomAnimationController

#import "TGRImageViewController.h"
#import "TGRImageZoomAnimationController.h"

@interface MyViewController () <UIViewControllerTransitioningDelegate>
@end

@implementation MyViewController
...
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    if ([presented isKindOfClass:TGRImageViewController.class]) {
        return [[TGRImageZoomAnimationController alloc] initWithReferenceImageView:self.imageView];
    }
    return nil;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    if ([dismissed isKindOfClass:TGRImageViewController.class]) {
        return [[TGRImageZoomAnimationController alloc] initWithReferenceImageView:self.imageView];
    }
    return nil;
}

- (IBAction)showImageViewer {
    TGRImageViewController *viewController = [[TGRImageViewController alloc] initWithImage:self.imageView.image];
    // Don't forget to set ourselves as the transition delegate
    viewController.transitioningDelegate = self;

    [self presentViewController:viewController animated:YES completion:nil];
}

联系方式

Guillermo Gonzalez
@gonzalezreal

许可协议

Vertigo 适用于 MIT 许可协议。请参阅 LICENSE