什麼是簡單的iOS文本/標籤動畫的最佳解決方案?詳細信息:用戶需要在iOS屏幕上看到一個標籤,其數組中的文字更改爲10-15個字,一個字由一個白色的屏幕分隔開。顯示時間一個字爲800-900毫秒,顯示時間爲白色屏幕是500毫秒。有一種注意力測試。如何創建iOS簡單的文本動畫?
回答
如果你只是想閃光的話,你可以使用NSTimer
或只是performSelector
:
@interface ViewController()
@property (nonatomic, strong) NSArray *words;
@property (nonatomic) NSUInteger wordIndex;
@end
@implementation ViewController
static CGFloat const kWordShowInterval = 0.8;
static CGFloat const kWordHideInterval = 0.4;
- (void)viewDidLoad
{
[super viewDidLoad];
self.words = @[@"one", @"two", @"three", @"four"];
self.wordIndex = 0;
[self showWord];
}
- (void)showWord
{
if (self.wordIndex >= [self.words count])
return;
self.wordLabel.text = self.words[self.wordIndex];
[self performSelector:@selector(hideWord)
withObject:nil
afterDelay:kWordShowInterval];
}
- (void)hideWord
{
self.wordLabel.text = nil;
self.wordIndex++;
if (self.wordIndex < [self.words count])
{
[self performSelector:@selector(showWord)
withObject:nil
afterDelay:kWordHideInterval];
}
else
{
// all done, go ahead and invoke whatever you want to do when done presenting the words
}
}
@end
如果你想要做文本的出現或消失的一些動畫(如褪色它或出),您可以將其與animateWithDuration
或其他動畫構造結合使用。
羅布,謝謝,它很簡單Ÿ有用的例子。最好的問候。 – Alexander
太棒了!請注意,如果您希望即使其他UI元素正在進行(例如UIScrolLView),此動畫也會繼續更新,您需要使用NSRunLoopCommonModes安排定期處理。 – 2013-07-29 02:22:53
通常核心動畫是最好的方法。退房the documentation
我認爲不是。如果他真的想在標籤從文本變爲空白或回到['animateWithDuration']時進行動畫過渡(http://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView。 html#// apple_ref/doc/uid/TP40006816-CH3-SW109)會容易得多。但我認爲這不是問題。 – Rob
好的,什麼是可以事件/調度的開始顯示(對於NNString單詞:arrayWords)當新頁面將顯示?沒有用戶交互..感謝 – Alexander
- 1. 如何在android中創建一個簡單的文本動畫?
- 2. iOS的:簡單的動畫
- 3. 創建2d動畫的簡單工具?
- 4. 在iOS上創建動畫的簡單方法?
- 5. iOS:創建簡單的音頻波形動畫
- 6. 如何創建一個動畫塊IOS
- 7. 如何創建簡單的啓動畫面/頁面?
- 8. 如何創建一個簡單的python動畫
- 9. 如何創建簡單的遊戲動畫
- 10. 如何在任務欄中創建一個簡單的動畫?
- 11. 如何使用WriteableBitmap創建簡單的動畫?
- 12. 如何創建3gp格式的簡單動畫?
- 13. 如何使用spritebuilder創建簡單的啓動畫面?
- 14. 如何在IOS 10中創建動畫作爲iMessage的動畫?
- 15. 如何使用java爲簡單形狀創建動畫?
- 16. 簡單的文字動畫
- 17. 帶有簡單動畫的iOS UIViewController
- 18. IOS簡單的條形圖動畫
- 19. 如何判斷iOS中的簡單png動畫何時完成?
- 20. 如何在Android中創建一個祕密的iOS應用文本動畫?
- 21. iOS中的動畫文本
- 22. 簡單,我如何在畫布中使用數組來創建多行動畫?
- 23. XNA windows phone 7如何創建簡單的文本輸入?
- 24. 如何用簡單的文本創建JFrame?
- 25. 簡單的動畫
- 26. Android(簡單的動畫創作)
- 27. 如何創建一個包含CHEF多行文本的簡單文本文件?
- 28. 如何創建波浪文字動畫?
- 29. 爲文本字段創建動畫
- 30. 在輸入文本上創建動畫
我以前只用NSTimer做過。它工作得很好。 –