如何使用 NSTimer 使图像 Alpha 变化/淡入淡出?
我正在 Xcode 中使用 Objective C 为 iphone 编写一个应用程序。我想做的是在我的应用程序启动时制作一个闪屏,持续大约 2 或 3 秒,我浏览了整个互联网,但所有关于如何执行此操作的教程都已过时,并且无法使用Xcode 和 Interface Builder 的当前版本。所以我想知道如何使用 NSTimer 发布图像大约 3 秒,然后将图像的 alpha 更改为 0。顺便说一句,我想知道如何在使用基于 Window 的应用程序预设时执行此操作。任何帮助将不胜感激,一个例子也可能会有所帮助。
I am programming an app for the iphone in Objective C in Xcode. What I am trying to do is to make a splash screen at the start of my app last for about 2 or 3 seconds, I have looked throughout the internet, but all of the tutorials on how to do this were outdated and did not work with the current versions of Xcode and Interface Builder. So I was wondering how would I use NSTimer to post an image for about 3 seconds and then change the alpha of the image to 0. By the way, I am wondering how to do this while using a Window Based Application preset. Any help would be greatly appreciated and an example would probably help as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 不喜欢看到闪屏。但如果您坚持的话,您是否尝试过仅设置
Default.png
图像?只需将名为Default.png
的图像拖到应用程序的“资源”文件夹中,启动画面就会在启动时显示。信息:
Default.png
的真正目的是让 UI 在应用真正准备好之前显示为“几乎准备好”状态,而这正是 Apple 想让您使用的这是为了,但应用程序不会因为在其启动屏幕上使用此功能而被拒绝。Apple does not like seeing splashscreens. But if you're insisting, have you tried just setting a
Default.png
image? Just drag an image calledDefault.png
into your App's "Resources" folder and your splashscreen will be shown at startup.Info: The real purpose of
Default.png
is to make the UI appear in an "almost ready" state before the app is actually ready and that's what Apple intends you to use this for, but apps don't get rejected for using this function for their Splashscreens.@大卫希弗是正确的。有关详细信息,请参阅 Apple 文档(向下滚动到应用程序启动图像)。
但是,如果您想实际实现某些内容,则可以按照建议进行操作并使用标准机制。然后
你可以在图像视图中抛出相同的图像(你的飞溅),然后使用像这样的动画块。
如果您每次启动应用程序时都需要它,请添加到此
@David Schiefer is correct. For more info see the Apple Docs (scroll down to Application Launch Images).
But if you wanted to actually implement something regardless you can do as suggested and use the standard mechanism. Then in
you could throw up the same image (your splash) in an imageview then use animation blocks like this.
If you want it every time the app is launched add to this instead