解决方案 »

  1.   

    这里主要涉及的知识点有如下几个:
    1. 如何设置这个点,以这个点为轴来左右调整
    这个点可以通过设置UIImageView layer 的anchorPoint来实现UIImageView *imgView =[ [UIImageView alloc] initWithImage:XXX];
    imgView.layer.anchorPoint= CGPointMake(0.5, 0.8);2. 设置好轴点,如何来实现旋转动画
    这里建议使用CABasicAnimation 来完成动画,这里有个链接有可以看一下
    http://www.cocoachina.com/bbs/read.php?tid=27152
      

  2.   

    imgView.layer.anchorPoint= CGPointMake(0.5, 0.8);  0.5是x不变,0.8是往上移动了。效果是可以实现了,但是图片位置发生改变了。
      

  3.   

    什么意思,因为设置了anchorPoint而导致图片的frame的orgin改生了改变? 是不是附加动画后导致的位置改变?
      

  4.   

     var shake = CABasicAnimation(keyPath: "transform.rotation.z")
            horse.layer.anchorPoint = CGPointMake(0.5, 0.8)   // (0.5,0.5)是以图片为中心晃动 而(0.5,0.8)会上移下 然后晃动。这两中方法晃动中心是不变的,只是图片上移而产生晃动点往下
            shake.fromValue = -0.2
            shake.toValue = +0.2
            shake.duration = 0.4
            shake.autoreverses = true
            shake.repeatCount = 4   //重复次数
           // [yourView.layer setAnchorPoint:CGPointMake(0, 0)];
            self.horse.layer.addAnimation(shake, forKey: "animateTransform")
      

  5.   

    这个很简单,因为默认情况下frame是从左上角(原点)开始,你设置了anchorPoint之后,原点发生了改变,frame的设置应该以修改后的原点为基准
      

  6.   

     var shake = CABasicAnimation(keyPath: "transform.rotation.z")
            horse.layer.anchorPoint = CGPointMake(0.5, 0.8)   // (0.5,0.5)是以图片为中心晃动 而(0.5,0.8)会上移下 然后晃动。这两中方法晃动中心是不变的,只是图片上移而产生晃动点往下
            shake.fromValue = -0.2
            shake.toValue = +0.2
            shake.duration = 0.4
            shake.autoreverses = true
            shake.repeatCount = 4   //重复次数
           // [yourView.layer setAnchorPoint:CGPointMake(0, 0)];
            self.horse.layer.addAnimation(shake, forKey: "animateTransform")看如下的帖子你就明白是怎么回事了
    http://www.cocoachina.com/bbs/read.php?tid=87118
      

  7.   


    每当修改一个CALayer的anchorPoint属性时,都要重新设置CALayer的position坐标。 给你的链接中有介绍
      

  8.   

    anchorPoint、position
    http://blog.csdn.net/zhangao0086/article/details/38356691