[英]Swapping text in iPhone by Animation
我想在IOS App中交換文本以指定幫助文本,我的意思是,我需要顯示
for a Xsec - "Touch me"
and then
for Xsec - "double tap".
使用CABasicAnimation是否可以? 文本需要在眨眼模式下顯示,在我繪制后立即繪制一個正方形。 所以我需要使文本閃爍60秒,然后每顯示10秒
The CAAnimation will take 60sec
0-10sec - "Touch me"
11-20sec - "double tap"
21-30sec - "Touch me"
....
51-60sec - "Double Tap"
據我所知,文本不是任何對象(UILabel,UITextView等)的可動畫化屬性,但是有許多控件可以將這些對象作為子類並允許可動畫化的文本(除其他屬性外)。 例如, AUIAnimateableText 。
不確定我是否理解您的問題,但是我會采取行動。
要更改用戶看到的內容的文本,您需要首先將其連接為iboutlet。 要更改文本,只需執行以下操作:
if ([myTextOutlet.text isEqualToString:@"Touch me"])
{
myTextOutlet.text = @"double tap";
}
else
{
myTextOutlet.text = @"Touch me";
}
為了獲得與實際為文本設置動畫效果接近的效果,您可以在其中包含2個UILabel
其中包含所需的文本並為其hidden
屬性設置動畫。 您可以做很多事情,只需淡入和淡出,甚至翻轉標簽或向左/向右滑動等等。如果您想獲得打字機效果,則可以在代碼中創建適當的UILabel
並使它們出現,等等。
至於時間,只需使用易於使用且有據可查的NSTimer
。
嘗試這個。,。
在這里,我正在更改標簽文本,..,
在viewdidload中有一個計時器。
- (void)viewDidLoad
{
label =[[UILabel alloc]initWithFrame:CGRectMake(367, 664, 220, 21)];
[label setText:@"Touch me"];
[label setBackgroundColor:[UIColor redColor]];
[label setTextColor:[UIColor blueColor]];
[self.view addSubview:label];
timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(loadtimer:) userInfo:nil repeats:YES];
}
int k=0;
-(void)loadtimer:(id)sender
{
label.text=(k%2) ? @"Touch me" : @"double tap";
[label setTextColor:( k% 2) ?[UIColor blueColor ]:[UIColor redColor]];
[label setBackgroundColor:( k% 2) ?[UIColor redColor ]:[UIColor blueColor]];
CATransition *transition1 = [CATransition animation];
transition1.duration = 1.0f;
transition1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition1.type = kCATransitionFade;
[label.layer addAnimation:transition1 forKey:nil];
k++;
}
調用此Loadtimer方法。取決於計時周期。 每5秒鍾調用一次LoadTimer方法,該方法將更改標簽的文本。
我在學習。,。,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.