[翻译] JFDepthView 给view提供3D景深

简介:

JFDepthView 给view提供3D景深

https://github.com/atljeremy/JFDepthView

 

This is an iOS project for presenting views in iOS with a 3D effect to add depth. JFDepthView is only available in ARC and targets iOS 7.0+.

这是一个iOS的工程项目,展示一个带有3D效果以及景深效果的view。JFDepthView仅仅支持ARC以及iOS 7.0+。

 

What's New:

February 26th, 2014

  • Added new animation options. In addition to the normal blur/push back affect you can now choose any of the following animation options. 支持更多种类动画

    • JFDepthViewAnimationOptionPushBack
    • JFDepthViewAnimationOptionPushBackAndBlur
    • JFDepthViewAnimationOptionPerspectiveTransform
    • JFDepthViewAnimationOptionPerspectiveTransformAndBlur
  • Removed previously deprecated initializer initWithGestureRecognizer: 移除之前废弃的初始化方法

  • Removed GPUImage dependency (Bad idea to add it in the first place, my bad) 移除了GPUImage支持(把他加到工程中,我真蠢)
  • Reduced the number of frameworks needed down to only 3 (win!) 减少了需要支持的框架
  • Now targets iOS 7+ only 现在仅仅支持iOS7+
  • Code refactoring and optimization 代码重构以及优化
  • Added subtle bounce to presented view (Trust me, it's beautiful, like a baby unicorn) 增加了子标题来展示view

January 29th, 2013

  • JFDepthView now supports both iPad and iPhone. 目前已经支持iPad和iPhone了

 

What It Looks Like:

Video

See it in action here: http://www.youtube.com/watch?v=X5lmn5y-FUw

iPad

iPhone

 

How To Use It:

Basic Example - 最基本的例子

#import <JFDepthView/JFDepthView.h>

...

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.topViewController = [[TopViewController alloc] initWithNibName:@"TopViewController" bundle:nil];
    UITapGestureRecognizer* tapRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
    self.depthView = [[JFDepthView alloc] init];
    self.depthView.delegate = self;

    // Optional properties, use these to customize your presentations
    // self.depthView.presentedViewWidth = 700;
    // self.depthView.presentedViewOriginY = 200;
    // self.depthView.blurAmount = JFDepthViewBlurAmountHard;
    // self.depthView.animationOption = JFDepthViewAnimationOptionPushBackAndBlur;
    self.depthView.recognizer = tapRec;
}

// Here is an IBAction that is called via a UIButton
- (IBAction)presentView:(id)sender {

    // Pass in the view controller you want to present (self.topViewController) 
    // and the view you want it to be displayed within (self.view)
    [self.depthView presentViewController:self.topViewController inView:self.view];

    // Optionally, if you don't care about rotation support, you can just pass in 
    // the view you want to present (self.topViewController.view) 
    // and the view you want it to be displayed within (self.view)
    // [self.depthView presentView:self.topViewController.view inView:self.view];
}

// Here is the simple dismissal method called from the tap recognizer passed into init method of JFDepthView
- (void)dismiss {
    [self.depthView dismissPresentedViewInView:self.view];
}

Customizable Properties - 可定制的属性

/**
 * JFDepthView - presentedViewWidth
 *
 * @return A custom float value representing the desired width of the presented view. Default value is 600.
 */
@property (nonatomic, assign) CGFloat presentedViewWidth;

/**
 * JFDepthView - presentedViewOriginY
 *
 * @return A custom float value representing the desired y origin of the presented view.
 * This is the space from the top of the presented view to the top of the view that it is contained in.
 */
@property (nonatomic, assign) CGFloat presentedViewOriginY;

/**
 * JFDepthView - blurAmount
 *
 * @return A JFDepthViewBlurAmount enum value representing to desired blur amount for the background view behind the presented view. Default value is JFDepthViewBlurAmountMedium.
 */
@property (nonatomic, assign) JFDepthViewBlurAmount blurAmount;

/**
 * JFDepthView - animationOption
 *
 * @return A JFDepthViewAnimationOption enum value representing the desired animation for the presentation. Default value is JFDepthViewAnimationOptionPerspectiveTransform.
 */
@property (nonatomic, assign) JFDepthViewAnimationOption animationOption;

/**
 * JFDepthView - hideStatusBarDuringPresentation
 *
 * @return A BOOL to tell JFDepthView to hide the status bar while presenting or not. Default is NO.
 */
@property (nonatomic, assign) BOOL hideStatusBarDuringPresentation;

/**
 * JFDepthView - recognizer
 *
 * @return The UIGestureRecognizer to be used on the area around the presentedView to dismiss the presentedView.
 */
@property (nonatomic, strong) UIGestureRecognizer* recognizer;

Add rotation support to your Presenting UIViewController - 支持UIViewController的旋转效果

#pragma mark - JFDepthView Rotation Support For Presenting UIViewController

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    [self.depthView didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [self.depthView willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

JFDepthView will notify your Presented UIViewController of the didRotate... and willRotate... events so you can do what ever customizations need to be done to your presented view

JFDepthView会监测你当前的UIViewController的旋转,如果旋转了他也会旋转。所以你可以做你想做的定制效果而无需担心旋转问题。

#pragma mark - JFDepthView Rotation Support for Presented UIViewController

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    NSLog(@"Top View Controller Received didRotateFromInterfaceOrientation: event from JFDepthView");
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    NSLog(@"Top View Controller Received willRotateToInterfaceOrientation:duration: event from JFDepthView");
}

Please see the example project include in this repo for an example of how to use this project.

看看demo就知道怎么回事了。

Delegate Methods:

- (void)willPresentDepthView:(JFDepthView*)depthView;
- (void)didPresentDepthView:(JFDepthView*)depthView;
- (void)willDismissDepthView:(JFDepthView*)depthView;
- (void)didDismissDepthView:(JFDepthView*)depthView;

 

Installation:

Add the JFDepthView project to your project

  • Simply copy the JFDepthView folder (containing the JFDepthView class and Vendor/ folder) into your project. 将文件夹JFDepthView拷贝到你的工程中即可

Add Dependencies

  • In your application's project app target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block找到添加框架的地方
  • Click the "+" button and add the following frameworks 添加以下框架

 

Current Known Issues As Of: Oct. 23rd, 2013

  • No known issues. If you find any, please report them using a GitHub Issue. Thanks! :) 还没有被报告过问题,欢迎你来提出bug。

 

 

目录
相关文章
|
Android开发
图+源码,读懂View的Layout方法
本篇文章就带大家学习 View 绘制三大方法的第二个方法——Layout 方法。
图+源码,读懂View的Layout方法
|
Android开发
图+源码,读懂View的Measure方法
本篇是 读懂View 系列的第二篇文章,本文将给大家正式开始讲解View绘制的三大方法,本篇将讲述第一个方法—— Measure 方法。
图+源码,读懂View的Measure方法
|
存储 Android开发
图+源码,读懂View的MeasureSpec
今天这篇文章,我们讲解的是 Measure 方法的前置知识,View的MeasureSpec类。
图+源码,读懂View的MeasureSpec
|
iOS开发 vr&ar
iOS开发-获取View截图图像
在做ar的时候突然有取图的需求,小记 先指定图像的大小 UIGraphicsBeginImageContext(view.frame.size); 在指定的区域绘制图像 [view drawViewHierarchyInRect:view.
1421 0
|
缓存 Android开发
Android:随笔——对页面的View进行截图
转载请标明地址 QuincySx:[http://www.jianshu.com/p/71309b2bd0e7] 我们在做项目时,往往有一个这样的需求:就是对视图的一部分进行截图然后分享出去 这个功能很简单还是简单的看代码吧 ...
1024 0
|
API Android开发
Android官方开发文档Training系列课程中文版:创建自定义View之View的交互
写在前面的话:这一章很有价值,想要提升安卓知识的一定要读一读。不做安卓的也可以得到其它方面的提升。 原文地址:http://android.xsoftlab.net/training/custom-views/making-interactive.html UI的绘制只是自定义View的一部分。
1077 0