博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
翻页效果
阅读量:7080 次
发布时间:2019-06-28

本文共 2254 字,大约阅读时间需要 7 分钟。

翻页效果

 

效果

 

说明

修正以前的不妥之处。

 

源码

////  PageFlipEffectController.m//  Animations////  Created by YouXianMing on 16/1/6.//  Copyright © 2016年 YouXianMing. All rights reserved.//#import "PageFlipEffectController.h"#import "Math.h"#import "WxHxD.h"#import "CALayer+SetRect.h"#import "UIView+SetRect.h"@interface PageFlipEffectController ()@property (nonatomic, strong) CALayer *layer;@property (nonatomic, strong) Math    *math;@end@implementation PageFlipEffectController- (void)setup {    [super setup];        // layer    _layer               = [CALayer layer];    _layer.anchorPoint   = CGPointMake(1.f, 0.5f);    _layer.frame         = CGRectMake(0, 0, Width / 2.f, 300);    _layer.x             = 0;    _layer.position      = CGPointMake(Width / 2.f, self.contentView.middleY);    _layer.contents      = (__bridge id)([UIImage imageNamed:@"pic_1"].CGImage);    _layer.borderColor   = [UIColor blackColor].CGColor;    _layer.borderWidth   = 4.f;    _layer.masksToBounds = YES;    _layer.transform = CATransform3DMakeRotation([Math radianFromDegree:0], 0.0, 1.0, 0.0);    [self.contentView.layer addSublayer:_layer];        // 一元一次方程求解    self.math = [Math mathOnceLinearEquationWithPointA:MATHPointMake(0, 0) PointB:MATHPointMake(Width, 180)];        // 手势    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];    [self.view addGestureRecognizer:pan];}- (void)handlePan:(UIPanGestureRecognizer *)sender {        CGPoint curPoint = [sender locationInView:self.view];    CGFloat x        = curPoint.x;        // 初始化3D变换,获取默认值    CATransform3D perspectiveTransform = CATransform3DIdentity;        // 透视    perspectiveTransform.m34 = -1.0 / 2000.0;        // 空间旋转    perspectiveTransform = CATransform3DRotate(perspectiveTransform, [Math radianFromDegree: x * self.math.k], 0, 1, 0);        [CATransaction setDisableActions:YES];    _layer.transform = perspectiveTransform;        if (x >= Width / 2.f) {                [CATransaction setDisableActions:YES];        _layer.contents = (__bridge id)([UIImage imageNamed:@"pic_2"].CGImage);            } else {                [CATransaction setDisableActions:YES];        _layer.contents = (__bridge id)([UIImage imageNamed:@"pic_1"].CGImage);    }}@end

细节

 

转载地址:http://xtjml.baihongyu.com/

你可能感兴趣的文章
mongodb - collMod
查看>>
学生如何提高专业英文阅读能力--施一公教授
查看>>
回顾2011,展望2012
查看>>
Android实例RSS客户端开发(3)--rss列表并显示在ui上
查看>>
PCI总线原理(四)
查看>>
unity, 设置帧率上限
查看>>
linux watchdog demo hacking
查看>>
两个函数连续性的讨论
查看>>
从头開始写项目Makefile(五):嵌套运行
查看>>
linux包之bash之内置命令ulimit
查看>>
QQ等软件可以联网 网页打不开
查看>>
c++ 使用socket实现C/S端文件的下载传输
查看>>
JMF获取设备列表失败,获取视频设备失败?
查看>>
Python模块学习 ---- datetime
查看>>
MS SQL Server Quarter Function
查看>>
linux日志(常用命令)
查看>>
Leetcode: Arranging Coins
查看>>
HttpUtil 【判断网络连接的封装类】
查看>>
【转】TCP分段与IP分片
查看>>
iOS 多线程 NSOperation、NSOperationQueue
查看>>