Ios UILabel在两个文本字符串之间重复淡入
我是iOS编程新手……我试图在用户点击按钮时,在一个标签内设置两个文本字符串之间的转换动画 到目前为止,我似乎已经使用嵌套/多级块动画适当地处理了淡入淡出。然而,即使使用Ios UILabel在两个文本字符串之间重复淡入,ios,objective-c,uilabel,fade,repeat,Ios,Objective C,Uilabel,Fade,Repeat,我是iOS编程新手……我试图在用户点击按钮时,在一个标签内设置两个文本字符串之间的转换动画 到目前为止,我似乎已经使用嵌套/多级块动画适当地处理了淡入淡出。然而,即使使用UIViewAnimationOptionRepeat&UIViewAnimationOptionAutoreverse它也拒绝连续重复自己(直到用户点击另一个按钮)。有什么想法吗?!提前谢谢 - (IBAction)FadeButtonPress:(id)sender { [UIView animateWithDuratio
UIViewAnimationOptionRepeat
&UIViewAnimationOptionAutoreverse
它也拒绝连续重复自己(直到用户点击另一个按钮)。有什么想法吗?!提前谢谢
- (IBAction)FadeButtonPress:(id)sender {
[UIView animateWithDuration:1.0
delay:0
options: UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{ _FadeLabel.text = @"AAAA";
[_FadeLabel setAlpha:1.0f ]; }
completion:^(BOOL finished) {
[UIView animateWithDuration:1.0
delay:0
options: nil
animations:^{ [_FadeLabel setAlpha:0.0f]; }
completion:^(BOOL finished) {
[UIView animateWithDuration:1.0
delay:0
options: nil
animations:^{_FadeLabel.text = @"BBBB";
[_FadeLabel setAlpha:1.0f ]; }
completion:^(BOOL finished) {
[UIView animateWithDuration:1.0
delay:0
options: nil
animations:^{ [_FadeLabel setAlpha:0.0f]; }
completion:^(BOOL finished) {
}]; }]; }]; }];
}
试试这个
- (IBAction)FadeButtonPress:(id)sender {
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear animations:^{
if ([_labe.text isEqualToString:@"Text 1"]) {
[_labe setText:@"Text 2"];
} else {
[_labe setText:@"Text 1"];
}
[self.labe setAlpha: 1];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.5 animations:^{
[self.labe setAlpha: 0];
} completion:^(BOOL finished) {
[self FadeButtonPress:sender];
}];
}];
}
这看起来很有希望!是否有方法在不使用[self FadeButtonPress:sender]的情况下重复此操作;最后?同一个按钮正在做一大堆其他的事情。。。