Git Product home page Git Product logo

ios_core_animation_advanced_techniques's People

Contributors

dorayo avatar zsisme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios_core_animation_advanced_techniques's Issues

4.6 组透明

按钮和表情都是白色背景
"表情"应为标签

Chapter 5.1放射变换

代码的注释错了
- (void)viewDidLoad { [super viewDidLoad]; //create a new transform CGAffineTransform transform = CGAffineTransformIdentity; //scale by 50% transform = CGAffineTransformScale(transform, 0.5, 0.5); //rotate by 30 degrees transform = CGAffineTransformRotate(transform, M_PI / 180.0 * 30.0); //translate by 200 points transform = CGAffineTransformTranslate(transform, 200, 0); //apply transform to layer self.layerView.layer.affineTransform = transform; }

应该为
- (void)viewDidLoad { [super viewDidLoad]; CGAffineTransform transform = CGAffineTransformIdentity;//create a new transform transform = CGAffineTransformScale(transform, 0.5, 0.5); //scale by 50% transform = CGAffineTransformRotate(transform, M_PI / 180.0 * 30.0); //rotate by 30 degrees transform = CGAffineTransformTranslate(transform, 200, 0);//translate by 200 points //apply transform to layer self.layerView.layer.affineTransform = transform; }

41页图3.3附近关于anchorPoint的描述和Xcode注释有悖。

41页图3.3附近关于anchorPoint的描述

w1

Xcode8关于anchorPoint的注释

/* Defines the anchor point of the layer's bounds rect, as a point in
* normalized layer coordinates - '(0, 0)' is the bottom left corner of
* the bounds rect, '(1, 1)' is the top right corner. Defaults to
* '(0.5, 0.5)', i.e. the center of the bounds rect. Animatable. */

@Property CGPoint anchorPoint;

到底哪里出了问题^_^

Chapter 3.1 Hit Testing 中 关于 hitTest 与 zPosition的论述经过测试有误

注意当调用图层的-hitTest:方法时,测算的顺序严格依赖于图层树当中的图层顺序(和UIView处理事件类似)。之前提到的zPosition属性可以明显改变屏幕上图层的顺序,但不能改变事件传递的顺序。
这意味着如果改变了图层的z轴顺序,你会发现将不能够检测到最前方的视图点击事件,这是因为被另一个图层遮盖住了,虽然它的zPosition值较小,但是在图层树中的顺序靠前。我们将在第五章详细讨论这个问题。

论述说 改变zPosition值不会改变 hitTest:方法的返回值,但是经过如下示例代码测试,发现改变zPosition值会改变 hitTest:方法的返回值。

示例代码:

- (void)addSomeLayers{
    self.tempLayer = [CALayer layer];
    self.tempLayer.backgroundColor = [UIColor blueColor].CGColor;
    self.tempLayer.frame = CGRectMake(100, 100, 200, 200);
    [self.view.layer addSublayer:self.tempLayer];
    
    self.redLayer = [CALayer layer];
    self.redLayer.backgroundColor = [UIColor redColor].CGColor;
    self.redLayer.frame = CGRectMake(50, 50, 50, 50);
    [self.tempLayer addSublayer:self.redLayer];
    
    self.yellowLayer = [CALayer layer];
    self.yellowLayer.backgroundColor = [UIColor yellowColor].CGColor;
    self.yellowLayer.frame = CGRectMake(75, 75, 100, 100);
    [self.tempLayer addSublayer:self.yellowLayer];
    
    self.redLayer.zPosition = 1;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UITouch *anyTouch = [touches anyObject];
    CGPoint point = [anyTouch locationInView:self.view];
    
    CALayer *layer = [self.view.layer hitTest:point];
    
    
    
    if (layer == self.tempLayer) {
        NSLog(@"touch blue layer");
    }
    else if (layer == self.view.layer){
        NSLog(@"touch self.view.layer");
    }
    else if(layer == self.redLayer){
        NSLog(@"touch red layer");
    }
    else if(layer == self.yellowLayer){
        NSLog(@"touch yellow layer");
    }
}

self.tempLayer上先后添加了self.redLayerself.yellowLayer,图层树中的顺序应该是self.yellowLayer在最上面,但是通过self.redLayer.zPosition = 1;改变self.redLayer的显示顺序后,hitTest:方法返回了self.redLayer

P48 第二行翻译错误

第二行原文:Note that there is no depth property to complement the bounds width and height.
翻译成了更深的属性。原文值的是“厚度”概念,类似于Thickness,说明layer 是扁平的,在z轴方向没有“纵深”。

《仿射变换》一节里的矩阵行列写反了

“因此,通常会用3×3(而不是2×3)的矩阵来做二维变换,你可能会见到3行2列格式的矩阵,这是所谓的以列为主的格式,图5.1所示的是以行为主的格式,只要能保持一致,用哪种格式都无所谓。”

这个,括号里面应该是“3x2”。

9.2层级关系

这一张内容为空,在github中的md文件也只有目录。

清单8.4 使用KVC对动画打标签 代码有问题

我仔细看了下代码,按照那里的写法的确能够成功执行。但是我发现

- (void)setAngle:(CGFloat)angle forHand:(UIView *)handView animated:(BOOL)animated
{
    //generate transform
    CATransform3D transform = CATransform3DMakeRotation(angle, 0, 0, 1);
    if (animated) {
        //create transform animation
        CABasicAnimation *animation = [CABasicAnimation animation];
        [self updateHandsAnimated:NO];
        animation.keyPath = @"transform";
        animation.toValue = [NSValue valueWithCATransform3D:transform];
        animation.duration = 0.5;
        animation.delegate = self;
        [animation setValue:handView forKey:@"handView"];
        [handView.layer addAnimation:animation forKey:nil];
    } else {
        //set transform directly
        handView.layer.transform = transform;
    }
}

这段代码里面 修改成

- (void)setAngle:(CGFloat)angle forHand:(UIView *)handView animated:(BOOL)animated
{
    //generate transform
    CATransform3D transform = CATransform3DMakeRotation(angle, 0, 0, 1);
    handView.layer.transform = transform;
}

一样能成功执行,因为以上代码主要的作用只是做了一个transform转换,并没有达到CABasicAnimation的目的。我觉得其实作者想要实现的效果应该是

- (void)setAngle:(CGFloat )angle forHand:(UIImageView *)handView animated:(BOOL)animated
{
    CATransform3D transform = CATransform3DMakeRotation(angle, 0, 0, 1);
    if (animated) {
        CABasicAnimation *animation = [CABasicAnimation animation];
        animation.keyPath = @"transform";
        animation.toValue = [NSValue valueWithCATransform3D:transform];
        animation.duration = 0.5;
        animation.fillMode = kCAFillModeForwards;
        animation.removedOnCompletion = NO;
        [handView.layer addAnimation:animation forKey:nil];
    }
    else
    {
        handView.layer.transform = transform;
    }
}

作者可以参考下

图层几何学--》锚点

图层几何学--》锚点 没有内容。我下载了pdf和epub都没有。在线的也没有(或者是不是章节对应有问题)

7.1事务章节代码错误

@Property (nonatomic, weak) IBOutlet CALayer *colorLayer;
这行代码错误,首先不需要IBOutlet,同时不应该采用weak来保存对象,否则程序无法正常运行。
应该改成
@Property (nonatomic, strong) CALayer *colorLayer;

Chapter8.1

错别字
文章结尾处"已近",是不是应为“已经”

10.2自定义缓冲函数代码

直接用书上的代码,取得的两个点坐标不对,需改成如下:

float p1[2];
float p2[2];
[func getControlPointAtIndex:1 values:(float *)&p1];
[func getControlPointAtIndex:2 values:(float *)&p2];    
CGPoint point1 = CGPointMake(p1[0], p1[1]);
CGPoint point2 = CGPointMake(p2[0], p2[1]);

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx;有创建寄宿图吗?

你寄宿图那章说调用-drawRect:和- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx;都会创建寄宿图。我测试了一下在UIView(frame特别大)的时候重写-drawRect:内存急剧飙升确实应该产生了寄宿图。但是在测试layer的时候调用了- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx;内存并没有上升很多啊,感觉好像没有创建寄宿图的样子。

3D变换章节代码疑问

3D变换中,透视部分为什么采用CATransform3DMakeRotation函数没有作用,也设置了m34。但换成CATransform3Drotate属性则有作用

contentsRect小节

Figure 2.6 A custom contentsRect (left) and the displayed contents (right) 这个图片说明的翻译:图2.6 一个自定义的contentsRect(左)和之后(配置之后)显示的内容

Chipmunk 引入之后,项目编译就报错了.

报错信息如下,处理了很久不知道是什么原因,希望能给与解答.谢谢.
Undefined symbols for architecture arm64:
"_cpSpaceStep", referenced from:
-[ZJBKAnimationWithTimerVC stepBox:] in ZJBKAnimationWithTimerVC.o
"_cpSpaceEachShape", referenced from:
-[ZJBKAnimationWithTimerVC stepBox:] in ZJBKAnimationWithTimerVC.o
"_cpSpaceNew", referenced from:
-[ZJBKAnimationWithTimerVC p_physicalEngine] in ZJBKAnimationWithTimerVC.o
"_cpSpaceAddBody", referenced from:
-[ZJBKAnimationWithTimerVC p_physicalEngine] in ZJBKAnimationWithTimerVC.o
"_cpShapeFree", referenced from:
-[ZJCreate dealloc] in ZJCreate.o
"_cpBodyFree", referenced from:
-[ZJCreate dealloc] in ZJCreate.o
"_cpBodyActivate", referenced from:
_cpShapeSetFriction in ZJCreate.o
"_cpBodyNew", referenced from:
-[ZJCreate initWithFrame:] in ZJCreate.o
"_cpMomentForBox", referenced from:
-[ZJCreate initWithFrame:] in ZJCreate.o
"_cpPolyShapeNew", referenced from:
-[ZJCreate initWithFrame:] in ZJCreate.o
"_cpSpaceAddShape", referenced from:
-[ZJBKAnimationWithTimerVC p_physicalEngine] in ZJBKAnimationWithTimerVC.o
"_cpBodySetPos", referenced from:
-[ZJCreate initWithFrame:] in ZJCreate.o
ld: symbol(s) not found for architecture arm64

"固体对象"部分光亮和阴影部分 代码好像有问题

normal = GLKMatrix3MultiplyVector3(matrix3, normal);
计算出的结果为
(GLKVector3) normal = {
= (s = 0, t = 0, p = 0)
= (s = 0, t = 0, p = 0)
= (s = 0, t = 0, p = 0)
v = ([0] = 0, [1] = 0, [2] = 0)
}

normal = GLKVector3Normalize(normal);
计算出的结果为

(GLKVector3) normal = {
= (s = NaN, t = NaN, p = NaN)
= (s = NaN, t = NaN, p = NaN)
= (s = NaN, t = NaN, p = NaN)
v = ([0] = NaN, [1] = NaN, [2] = NaN)
}

《3D变换》一节里,矩阵行列写反了

“和CGAffineTransform类似,CATransform3D也是一个矩阵,但是和2x3的矩阵不同,CATransform3D是一个可以在3维空间内做变换的4x4的矩阵(图5.6)”

这里的“2X3”,应该是“3X2”。

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.