Iphone UIView在离开另一侧时是否重新出现在屏幕上?
我有一个叫做云的UIView。它当前移动到屏幕的右侧,当所有内容都离开后,它会重新出现在左侧 如何使其在右侧离开时重新显示在左侧?因此,当它开始从右侧离开时,刚刚消失的钻头会重新出现在左侧Iphone UIView在离开另一侧时是否重新出现在屏幕上?,iphone,animation,uiview,uiimageview,Iphone,Animation,Uiview,Uiimageview,我有一个叫做云的UIView。它当前移动到屏幕的右侧,当所有内容都离开后,它会重新出现在左侧 如何使其在右侧离开时重新显示在左侧?因此,当它开始从右侧离开时,刚刚消失的钻头会重新出现在左侧 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. movement = [NSTimer schedu
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
movement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(moving) userInfo:nil repeats:YES];
cloudsMovement = 2;
}
-(void)platformMovement{
clouds.center = CGPointMake(clouds.center.x + cloudsMovement, clouds.center.y);
}
-(void)moving{
if (clouds.center.x < -11){
clouds.center = CGPointMake(330, clouds.center.y);
}
if (clouds.center.x > 330){
clouds.center = CGPointMake(-11, clouds.center.y);
}
[self platformMovement];
}
-(void)viewDidLoad
{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
移动=[NSTimer scheduledTimerWithTimeInterval:0.05目标:自选择器:@selector(moving)userInfo:nil repeats:YES];
云移动=2;
}
-(空)平台运动{
clouds.center=CGPointMake(clouds.center.x+cloudsMovement,clouds.center.y);
}
-(无效)移动{
如果(云.中心.x<-11){
clouds.center=CGPointMake(330,clouds.center.y);
}
如果(云.center.x>330){
clouds.center=CGPointMake(-11,clouds.center.y);
}
[自我平台运动];
}
任何帮助都将不胜感激,谢谢 回答我自己的问题似乎有点不寻常,但为了帮助像我这样的初学者,我提出了以下解决方案: 创建另一个UIView(我称之为clouds2)。 将其从屏幕向左移动,并将其设置为原始UIView(clouds1)的动画。 稍微调整一下数字,这样当整个图像离开屏幕时,它会重新出现在左侧。有点像传送带系统
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
movement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(moving) userInfo:nil repeats:YES];
cloudsMovement = 2;
}
-(void)platformMovement{
clouds1.center = CGPointMake(clouds1.center.x + cloudsMovement, clouds1.center.y);
clouds2.center = CGPointMake(clouds2.center.x + cloudsMovement, clouds1.center.y);
}
-(void)moving{
if (clouds1.center.x > 470){
clouds1.center = CGPointMake(-150, clouds1.center.y);
}
if (clouds2.center.x > 470){
clouds2.center = CGPointMake(-150, clouds2.center.y);
}
[self platformMovement];
}
这是我的建议。