iphone – IOS CATransform3DMakeRotation需要帮助向量

iphone – IOS CATransform3DMakeRotation需要帮助向量,第1张

概述我正在尝试做一个页面翻转动画,并在互联网上找到此代码.这非常有效.它会像从正常的书一样从右到左制作翻页.我想修改代码使其从左到右,但我无法弄清楚矢量&锚点工作.注意这两行我认为需要改变.我只是不确定… viewToOpen.layer.anchorPoint = CGPointMake(0.0f, 0.5f); viewToOpen.center = CGPointMake 我正在尝试做一个页面翻转动画,并在互联网上找到此代码.这非常有效.它会像从正常的书一样从右到左制作翻页.我想修改代码使其从左到右,但我无法弄清楚矢量&锚点工作.注意这两行我认为需要改变.我只是不确定…

vIEwToOpen.layer.anchorPoint = CGPointMake(0.0f,0.5f);            vIEwToOpen.center = CGPointMake(vIEwToOpen.center.x - vIEwToOpen.bounds.size.wIDth/2.0f,vIEwToOpen.center.y);CAtransform3D endtransform = CAtransform3DMakeRotation(3.141f/2.0f,0.0f,-1.0f,0.0f);

全功能:

- (voID) pageOpenVIEw:(UIVIEw *)vIEwToOpen duration:(NSTimeInterval)duration {    // Remove existing animations before stating new animation    [vIEwToOpen.layer removeAllAnimations];    // Make sure vIEw is visible    vIEwToOpen.hIDden = NO;    // disable the vIEw so it’s not doing anythign while animating    vIEwToOpen.userInteractionEnabled = NO;    // Set the CALayer anchorPoint to the left edge and    // translate the button to account for the new    // anchorPoint. In case you want to reuse the animation    // for this button,we only do the translation and    // anchor point setting once.    if (vIEwToOpen.layer.anchorPoint.x != 0.0f) {        vIEwToOpen.layer.anchorPoint = CGPointMake(0.0f,0.5f);        vIEwToOpen.center = CGPointMake(vIEwToOpen.center.x - vIEwToOpen.bounds.size.wIDth/2.0f,vIEwToOpen.center.y);    }    // create an animation to hold the page turning    CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];    transformAnimation.removedOnCompletion = NO;    transformAnimation.duration = duration;    transformAnimation.timingFunction = [camediatimingFunction functionWithname:kcamediatimingFunctionEaseInEaSEOut];    // start the animation from the current state    transformAnimation.fromValue = [NSValue valueWithCAtransform3D:CAtransform3DIDentity];    // this is the basic rotation by 90 degree along the y-axis    CAtransform3D endtransform = CAtransform3DMakeRotation(3.141f/2.0f,0.0f);    // these values control the 3D projection outlook    endtransform.m34 = 0.001f;    endtransform.m14 = -0.0015f;    transformAnimation.tovalue = [NSValue valueWithCAtransform3D:endtransform];    // Create an animation group to hold the rotation    CAAnimationGroup *theGroup = [CAAnimationGroup animation];    // Set self as the delegate to receive notification when the animation finishes    theGroup.delegate = self;    theGroup.duration = duration;    // CAAnimation-objects support arbitrary Key-Value pairs,we add the UIVIEw tag    // to IDentify the animation later when it finishes    [theGroup setValue:[NSNumber numberWithInt:vIEwToOpen.tag] forKey:@"vIEwToOpenTag"];    // Here you Could add other animations to the array    theGroup.animations = [NSArray arrayWithObjects:transformAnimation,nil];    theGroup.removedOnCompletion = NO;    // Add the animation group to the layer    [vIEwToOpen.layer addAnimation:theGroup forKey:@"flipVIEwOpen"];}
解决方法 它可能取决于图层和视图设置,但基本上

vIEwToOpen.layer.anchorPoint = CGPointMake(1.0f,0.5f);CAtransform3D endtransform = CAtransform3DMakeRotation(-M_PI/2.0f,1.0f,0.0f)

完整的代码如下所示:

self.layer.anchorPoint = CGPointMake(1.0f,0.5f);self.layer.position = CGPointMake(self.layer.position.x + self.bounds.size.wIDth/2.0f,self.layer.position.y);CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];animation.duration = 0.75f;animation.timingFunction = [camediatimingFunction functionWithname:kcamediatimingFunctionEaseInEaSEOut];CAtransform3D tfm = CAtransform3DMakeRotation(M_PI/2.0f,0.0f);tfm.m34 = 0.001f;tfm.m14 = -0.0015f;animation.fromValue = [NSValue valueWithCAtransform3D:CAtransform3DIDentity];animation.tovalue = [NSValue valueWithCAtransform3D:tfm];[self.layer addAnimation:animation forKey:@"flipUp"];
总结

以上是内存溢出为你收集整理的iphone – IOS CATransform3DMakeRotation需要帮助向量全部内容,希望文章能够帮你解决iphone – IOS CATransform3DMakeRotation需要帮助向量所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1079261.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存