Git Product home page Git Product logo

fytransition's Introduction



框架说明 DESC

.本框架可以快速集成图片过渡转场动画,目前有push和modal两种方式,呈现方式为zoom放大动画效果.

效果图展示

push方式

image


modal方式

image


一.简单上手(使用默认方式)

1.在.h文件中继承父类

/**
 *  使用默认的方式,导入头文件 FYTransitionController.h
 *  创建一个继承自 FYTransitionController 的子类控制器即可
 */
@interface ImageViewController : FYTransitionController 

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@end

2.push或者modal出控制器

UIImageView *oImageView = [[UIImageView alloc] initWithImage:cell.imageView.image];
oImageView.frame =[cell.imageView convertRect:cell.imageView.frame toView:self.view];

ImageViewController *imageVC = [[ImageViewController alloc] initWithOriginalImageView:oImageView];
imageVC.view.backgroundColor = [UIColor darkGrayColor];

//一定得设置代理,不然自动转场动画无法生效
imageVC.transitioningDelegate = imageVC;
[self presentViewController:imageVC animated:YES completion:^{
    imageVC.titleLabel.text = cell.label.text;
}];



二.自定义图片(图片在下一个控制器的位置)的位置

1.在.h文件中继承父类并遵守协议

/**
 *  导入头文件 FYTransitionController.h
 *  创建一个继承自 FYTransitionController 的子类控制器,并且遵守 FYTransitionProtocol 协议
 */
@interface CustomViewController : FYTransitionController <FYTransitionProtocol>

@end

2.在.m文件中实现协议方法

/**
 *   返回imageView的位置,需要特别注意的是,如果使用xib布局的话,不能直接返回控件的frame,
 * 因为控件还未初始化,所以在这里得用代码设置imageView的位置
 *
 *  @return 返回imageView在其父控件的frame
 */
- (CGRect)fy_transitionFinalImageViewFrame{
    return  CGRectMake(10, 65, 300, 300);
}

/**
 *   动画完成后的回调,获得最终imageView,在此回调中将imageView添加到父控件中,
 * 在下面的方法中没有添加 imageView 的相关代码是因为使用了xib,直接赋值就好了
 *
 *  @param imageView 回调传值
 */
- (void)fy_transitionCompleteAnimateImageView:(UIImageView *)imageView{
    self.mainImageView.image = imageView.image;
    self.mainImageView.backgroundColor = [UIColor greenColor];
    self.mainImageView.userInteractionEnabled = YES;
    self.mainImageView.clipsToBounds = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFinalImageView:)];
    [self.mainImageView addGestureRecognizer:tapGesture];
}

- (void)tapFinalImageView:(UITapGestureRecognizer *)tapGesture{

    if (self.navigationController.delegate == self) {
        [self.navigationController popViewControllerAnimated:YES];
    } else if (self.transitioningDelegate == self) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }

}

3.push或者modal出控制器

UIImageView *oImageView = [[UIImageView alloc] initWithImage:cell.imageView.image];
oImageView.frame =[cell.imageView convertRect:cell.imageView.frame toView:self.view];

ImageViewController *imageVC = [[ImageViewController alloc] initWithOriginalImageView:oImageView];

//一定得设置代理,不然自动转场动画无法生效
self.navigationController.delegate = imageVC;
[self.navigationController pushViewController:imageVC animated:YES];



tips

.目前正在研发更好的实现方式,更新中...



fytransition's People

Contributors

tongfangyuan avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.