如何在整个屏幕上移动的几个按钮 [英] How to move several buttons throughout the screen

查看:161
本文介绍了如何在整个屏幕上移动的几个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个应用程序,我在屏幕上有几个按钮,我想使他们在整个屏幕上移动。用户可以点击其上的用户水龙头被从screen.Hence删除按钮和按键我必须停​​止其移动该按钮计时器。

I am creating an application where I have several buttons on the screen and I want to make them move throughout the screen. User can tap on that buttons and the buttons on which user taps gets removed from the screen.Hence I have to stop the timer which moves that button.

但我主要关注的是如何使所有的泡沫移动,即如何管理他们每个人的?

But my main concern is How to make all the bubbles move i.e. How to manage each of them?

我已经使用的NSTimer的。

I have made the use of NSTimer.

的NSTimer *计时器= [的NSTimer timerWithTimeInterval:1的目标:自我选择:@selector(moveTheButton)USERINFO:无重复:YES]; [NSRunLoop currentRunLoop] addTimer:定时器forMode:NSRunLoopCommonModes];

但是,这可能的情况下,有益的,如果我只有一个按钮。如果有更多的按钮其相当难以管理的定时器。

But this can be helpful in case if I have only one button. If there are more buttons its quite hard to manage the timers.

另外的按键数目是动态的。

Also the number of buttons are dynamic.

请提出一些备用。

我已经经历了几个线程了但没有得到预期的答案。

I have gone through few threads but didnt got the expected answer.

先谢谢您的帮助......

Thanks in advance for help.....

推荐答案

我会建议使用CAAnimations移动你的按钮。这将让您顺利动画的按钮,无需使用NSTimers的,也将是理想的动态创建按钮动画。

I would suggest using CAAnimations to move your buttons. This would allow you to animate your buttons smoothly without the use of NSTimers and would also be ideal for creating your button animations dynamically.

CAAnimations创建然后加至次层。您可以通过动画一个CAAnimations视图的旋转,位置和大小。这也很容易从一个观点层添加和删除动画,使其成为理想的无多NSTimers的头痛动态内容。

CAAnimations are created then added to a views layer. You can animate the rotation, position and size of a view using CAAnimations. It is also easy to add and remove animations from a views layer, making it ideal for dynamic content without the headache of multiple NSTimers.

这篇关于如何在整个屏幕上移动的几个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆