Ios 整个屏幕上的图像旋转和淡入
我的问题是,我有一个图像,我可以把它上下移动。但我想要的是图像应该在整个屏幕上随机移动。这个问题在堆栈上可能会以不同的方式被问到,但我无法理解。此外,图像在移动时会褪色,当我触摸/单击图像时,它会给我一个不同的视图Ios 整个屏幕上的图像旋转和淡入,ios,animation,uiimage,Ios,Animation,Uiimage,我的问题是,我有一个图像,我可以把它上下移动。但我想要的是图像应该在整个屏幕上随机移动。这个问题在堆栈上可能会以不同的方式被问到,但我无法理解。此外,图像在移动时会褪色,当我触摸/单击图像时,它会给我一个不同的视图 timer=[NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; UITapGestureRecognizer
timer=[NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
UITapGestureRecognizer *recognizer=[[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
[self.view addGestureRecognizer:recognizer];
-(void)fadeMe
{
[UIView animateWithDuration:1.2f animations:^{
[view setAlpha:0.0f];
}
completion:^(BOOL finished){
[view setAlpha:1.0f];
isBackgroundrunning=NO;
}];
}
-(void)onTimer{
if(arc4random() % 10 == 1)
{
if (!isBackgroundrunning) {
[self performSelectorInBackground:@selector(fadeMe) withObject:nil];
isBackgroundrunning=YES;
}
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
CGPoint pt=[touch locationInView:self.view];
CGRect applebounds=[view frame];
if (pt.x>applebounds.origin.x && pt.x<applebounds.origin.x+applebounds.size.width && pt.y>applebounds.origin.y && pt.y<applebounds.origin.y+applebounds.size.height) {
[timer invalidate];
applebounds.size.height*=2;
applebounds.size.width*=2;
[UIView animateWithDuration:0.3 animations:^{
[view setFrame:applebounds];
} completion:^(BOOL finished) {
[view removeFromSuperview];
//perform your task here .....
}];
}
}