旋转动画xcode iphone

旋转动画xcode iphone,第1张

概述我试图使用 xcode中的简单单一视图应用程序围绕圆圈旋转图像.我在主故事板上有一个圆圈图像和一个按钮.我使用下面的代码,但圆形图像向下漂移,然后向左旋转,随着它的旋转.我不确定它缺少什么. 谢谢你的帮助. ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController { 我试图使用 xcode中的简单单一视图应用程序围绕圆圈旋转图像.我在主故事板上有一个圆圈图像和一个按钮.我使用下面的代码,但圆形图像向下漂移,然后向左旋转,随着它的旋转.我不确定它缺少什么.

谢谢你的帮助.

VIEwController.h

#import <UIKit/UIKit.h> @interface VIEwController : UIVIEwController {         IBOutlet UIImageVIEw *theImageVIEw;         IBOutlet UIbutton    *thebutton;         NSTimer              *theTimer;         float        angle;         BOol         runStop;     } @property (atomic,retain) IBOutlet UIImageVIEw *theImageVIEw; @property (atomic,retain) IBOutlet UIbutton    *thebutton; -(IBAction)runRoulette:(ID)sender; @end

VIEwController.m

#import "VIEwController.h"@interface VIEwController ()@end@implementation VIEwController@synthesize thebutton,theImageVIEw;- (voID)vIEwDIDLoad{    angle = 0;    runStop = FALSE;    [super vIEwDIDLoad];    // Do any additional setup after loading the vIEw,typically from a nib.}- (voID)dIDReceiveMemoryWarning{    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}-(voID)rotateRoulette{    theImageVIEw.center = CGPointMake(self.theImageVIEw.center.x,self.theImageVIEw.center.y);    theImageVIEw.transform=CGAffinetransformMakeRotation (angle);    angle+=0.001;}-(IBAction)runRoulette:(ID)sender{    if(!runStop)    {        theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/600.0 target:self selector:@selector(rotateRoulette) userInfo:nil repeats:YES];    }    else    {        [theTimer invalIDate];        theTimer = nil;    }    runStop = !runStop;}@end
解决方法 我找到了一种非常简单的方法来让我的动画工作我也想要它 –

theImageVIEw.center = CGPointMake(160.0,364.0);[UIVIEw beginAnimations:nil context:NulL];[UIVIEw setAnimationDuration:5];//theImageVIEw.center=CGPointMake(self.theImageVIEw.center.x,self.theImageVIEw.center.y);theImageVIEw.transform = CGAffinetransformMakeRotation(M_PI/2.65);[UIVIEw commitAnimations];

它旋转theImageVIEw M_PI / 2.65(M_PI / 2.65是roataion数量),计数为5.

总结

以上是内存溢出为你收集整理的旋转动画xcode iphone全部内容,希望文章能够帮你解决旋转动画xcode iphone所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1007372.html

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

发表评论

登录后才能评论

评论列表(0条)

保存