<tfoot id='Kf0z2'></tfoot>

    <legend id='Kf0z2'><style id='Kf0z2'><dir id='Kf0z2'><q id='Kf0z2'></q></dir></style></legend>
      <bdo id='Kf0z2'></bdo><ul id='Kf0z2'></ul>

    <small id='Kf0z2'></small><noframes id='Kf0z2'>

        <i id='Kf0z2'><tr id='Kf0z2'><dt id='Kf0z2'><q id='Kf0z2'><span id='Kf0z2'><b id='Kf0z2'><form id='Kf0z2'><ins id='Kf0z2'></ins><ul id='Kf0z2'></ul><sub id='Kf0z2'></sub></form><legend id='Kf0z2'></legend><bdo id='Kf0z2'><pre id='Kf0z2'><center id='Kf0z2'></center></pre></bdo></b><th id='Kf0z2'></th></span></q></dt></tr></i><div id='Kf0z2'><tfoot id='Kf0z2'></tfoot><dl id='Kf0z2'><fieldset id='Kf0z2'></fieldset></dl></div>

        围绕其中心点旋转 UIImageView?

        Rotate UIImageView around its center point?(围绕其中心点旋转 UIImageView?)

        <small id='sScjE'></small><noframes id='sScjE'>

              <tbody id='sScjE'></tbody>

                <bdo id='sScjE'></bdo><ul id='sScjE'></ul>
                <i id='sScjE'><tr id='sScjE'><dt id='sScjE'><q id='sScjE'><span id='sScjE'><b id='sScjE'><form id='sScjE'><ins id='sScjE'></ins><ul id='sScjE'></ul><sub id='sScjE'></sub></form><legend id='sScjE'></legend><bdo id='sScjE'><pre id='sScjE'><center id='sScjE'></center></pre></bdo></b><th id='sScjE'></th></span></q></dt></tr></i><div id='sScjE'><tfoot id='sScjE'></tfoot><dl id='sScjE'><fieldset id='sScjE'></fieldset></dl></div>
                <legend id='sScjE'><style id='sScjE'><dir id='sScjE'><q id='sScjE'></q></dir></style></legend>
              • <tfoot id='sScjE'></tfoot>

                • 本文介绍了围绕其中心点旋转 UIImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想要围绕其中心点旋转的 UIImageView (self.myImage) 中有一个透明 png.代码应该很简单:

                  I have a transparent png inside a UIImageView (self.myImage) that I want to rotate around its center point. The code should be pretty simple:

                  [self.myImage.layer setAnchorPoint:CGPointMake(0.5, 0.5)];
                  [UIView animateWithDuration:1.0 animations:^{
                      [self.myImage setTransform:CGAffineTransformMakeRotation(angle)];
                  }];
                  

                  图像以正确的速度/时间和正确的角度旋转,但其位置发生了偏移.这是正在发生的事情的一个示例:

                  The image rotates at the right speed/time and at the right angle, but its position gets shifted. Here's an example of what's happening:

                  灰色方块只是为了显示在屏幕上的位置.另一个图是透明的 png(包含在 UIImageView 中).白色虚线显示 UIImageView 的中心.图像左侧显示图像的原始位置,右侧显示使用上述代码旋转后的图像(向右移动一点).黑白圆圈位于图像文件的中心.

                  The gray square is just to show position in the screen. The transparent png (contained in a UIImageView) is the other figure. The white dotted lines show the center of the UIImageView. The left side of the image shows the original position of the image, the right side shows the image after being rotated with the above code (which gets shifted a little down to the right). The black and white circles are in the center of the image file.

                  我有什么遗漏的吗?据我了解,上面的第一行不是必需的,因为这些是默认值.我是否必须在情节提要中/以编程方式设置/取消设置某些内容?

                  Is there something that I'm missing? As far as I understand, the first line above is not required because those are the defaults. Do I have to set/unset something in the storyboard/programmatically?

                  推荐答案

                  我发现完成我需要的代码比@Albin Joseph 给出的代码更简单,但它确实为我指明了正确的方向.我的动画需要从中断的地方重新开始并旋转到新位置.有时它会被动画化,有时则不会.所以代码如下:

                  I found out that the code I need to accomplish what I needed was simpler than the one given by @Albin Joseph, but it did point me to the right direction. My animation needs to pick up where it left off and rotate to a new position. Some times it will be animated and sometimes it won't. So hence the code:

                  CGFloat duration = animated ? 0.5 : 0.01;
                  
                  CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
                  animation.fromValue = [[self.turnIndicatorImage.layer presentationLayer] valueForKeyPath:@"transform.rotation.z"];
                  animation.toValue = angle;
                  animation.duration = duration;
                  animation.fillMode = kCAFillModeForwards;
                  animation.repeatCount = 0;
                  animation.removedOnCompletion = NO;
                  animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
                  [self.turnIndicatorImage.layer addAnimation:animation forKey:@"transform.rotation.z"];
                  

                  这篇关于围绕其中心点旋转 UIImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  Difference between retain and copy?(保留和复制的区别?)
                  Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                  When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                  Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                  <i id='7LMBP'><tr id='7LMBP'><dt id='7LMBP'><q id='7LMBP'><span id='7LMBP'><b id='7LMBP'><form id='7LMBP'><ins id='7LMBP'></ins><ul id='7LMBP'></ul><sub id='7LMBP'></sub></form><legend id='7LMBP'></legend><bdo id='7LMBP'><pre id='7LMBP'><center id='7LMBP'></center></pre></bdo></b><th id='7LMBP'></th></span></q></dt></tr></i><div id='7LMBP'><tfoot id='7LMBP'></tfoot><dl id='7LMBP'><fieldset id='7LMBP'></fieldset></dl></div>

                            <bdo id='7LMBP'></bdo><ul id='7LMBP'></ul>
                              <tbody id='7LMBP'></tbody>

                            <small id='7LMBP'></small><noframes id='7LMBP'>

                            <tfoot id='7LMBP'></tfoot>

                            <legend id='7LMBP'><style id='7LMBP'><dir id='7LMBP'><q id='7LMBP'></q></dir></style></legend>