Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 沿圆周方向移动图像视图_Iphone_Cocoa Touch_Uiimageview_Core Animation_Core Graphics - Fatal编程技术网

Iphone 沿圆周方向移动图像视图

Iphone 沿圆周方向移动图像视图,iphone,cocoa-touch,uiimageview,core-animation,core-graphics,Iphone,Cocoa Touch,Uiimageview,Core Animation,Core Graphics,我尝试了这段代码,但没有用,我想在循环路径中移动图像视图您想要的动画可以在不使用CAAnimation类的情况下完成 在NSTimer对象中使用以下代码 制作一个循环,其中角度变量从0开始到无穷大或360的倍数 //半径是要在其中移动图像视图的圆半径 [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; CGRect frame = [butt

我尝试了这段代码,但没有用,我想在循环路径中移动图像视图

您想要的动画可以在不使用CAAnimation类的情况下完成

在NSTimer对象中使用以下代码

制作一个循环,其中角度变量从0开始到无穷大或360的倍数

//半径是要在其中移动图像视图的圆半径

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
CGRect frame = [button frame];
button.layer.anchorPoint = CGPointMake(0.5, 0.5);
button.layer.position = CGPointMake(frame.origin.x + 0.5 * frame.size.width, frame.origin.y + 0.5 * frame.size.height);
[CATransaction commit];

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions];
[CATransaction setValue:[NSNumber numberWithFloat:2.0] forKey:kCATransactionAnimationDuration];

CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
animation.delegate = self;
[button.layer addAnimation:animation forKey:@"rotationAnimation"];

[CATransaction commit];

请检查运动图像的此代码。。。谢谢

myImageView.center = CGPointMake(myImageView.center.x + cos(angle) * radius, myImageView.center.y + sin (angle) * radius);

bt上面的代码将通过其中心旋转图像视图,我们希望图像视图沿任意点旋转。嗨,我需要图像视图不断朝那个方向移动
    UIBezierPath *customPath =[self createArcPath];

    UIImage *movingImage = [UIImage imageNamed:@"Unchecked.png"];
    CALayer *movingLayer = [CALayer layer];
    movingLayer.contents = (id)movingImage.CGImage;
    movingLayer.anchorPoint = CGPointZero;
    movingLayer.frame = CGRectMake(0.0f, 0.0f, movingImage.size.width, movingImage.size.height); // image position starting 
    [self.view.layer addSublayer:movingLayer];

    CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.duration = 4.0f;
    pathAnimation.path = customPath.CGPath;
    pathAnimation.calculationMode = kCAAnimationLinear;
    [movingLayer addAnimation:pathAnimation forKey:@"movingAnimation"];

}
  - (UIBezierPath *)createArcPath
    {
        UIBezierPath *aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150)
                                                             radius:10
                                                         startAngle:0
                                                           endAngle:2* M_PI
                                                          clockwise:YES];
        return aPath;
    }