我的應用必須根據用戶的選擇做一個計算和動畫,並且在動畫中使用它之前我需要更新UILabel
,問題是每當我設置UILabel
文本時,它都會動畫化並且我有不知道爲什麼。我試過[self.view.layer removeAllAnimations];在更改UILabel
文字之前仍然沒有好處。我甚至嘗試以編程方式調用IBAction
並更改UILabel
來自該塊的文本,並且仍然弄亂了動畫。沒有什麼似乎工作,它是絕對的時機,因爲更改viewDidLoad中的UILabel
文本工作正常。我還通過在動畫和相同問題發生之前更改另一個UILabel
的文本來檢查它是否爲故事板問題。如果有幫助的一切都在這裏是動畫代碼:更改UILabel文字動畫?
-(IBAction) swipeDown:(UISwipeGestureRecognizer *)recognizer{
multiply.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
subtract.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
add.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
divide.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
circle.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
signcircle.frame = CGRectMake(145.0f, 70.0f, signcircle.frame.size.width,signcircle.frame.size.height);
sign.frame = CGRectMake(152.0f, 68.0f, sign.frame.size.width,sign.frame.size.height);
[email protected]"multiply";
if(fivebutton.highlighted){
circle.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
multiply.transform = CGAffineTransformMakeScale(1.35f, 1.35f);
multiply.frame = CGRectMake(120.0f, 248.0f, multiply.frame.size.width, multiply.frame.size.height);
[UIView animateWithDuration:.25f animations:^{
add.frame = CGRectMake(130.0f, 202.0f, add.frame.size.width, add.frame.size.height);
add.alpha=1.0;
subtract.frame = CGRectMake(82.0f, 255.0f, subtract.frame.size.width, subtract.frame.size.height);
subtract.alpha=1.0;
divide.frame = CGRectMake(178.0f, 255.0f, divide.frame.size.width, divide.frame.size.height);
divide.alpha=1.0;
multiply.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
multiply.frame = CGRectMake(130.0f, 305.0f, multiply.frame.size.width, divide.frame.size.height);
multiply.alpha=1.0;
circle.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
circle.alpha=1.0;
UIImage *downimage = [UIImage imageNamed: @"multiplydown.png"];
[multiply setImage:downimage];
onebutton.alpha=0.1;
one.alpha=0.1;
twobutton.alpha=0.1;
two.alpha=0.1;
threebutton.alpha=0.1;
three.alpha=0.1;
fourbutton.alpha=0.1;
four.alpha=0.1;
sixbutton.alpha=0.1;
six.alpha=0.1;
fivebutton.alpha=0.0;
sevenbutton.alpha=0.1;
seven.alpha=0.1;
eightbutton.alpha=0.1;
eight.alpha=0.1;
ninebutton.alpha=0.1;
nine.alpha=0.1;
zerobutton.alpha=0.1;
zero.alpha=0.1;
decimalbutton.alpha=0.1;
decimal.alpha=0.1;
equalsbutton.alpha=0.1;
equals.alpha=0.1;
}];
[UIView commitAnimations];
}
在這種情況下,UILabel
文本變化導致「加」,「減」,「分」與「乘」(UIImageView
的)在一起,而不是合併如動畫應該傳播一樣。
-(void) fiveTapEnded{
var2.hidden=NO;
if ([type isEqual:@"add"]) {
NSLog(@"Is add");
}
if ([type isEqual:@"subtract"]) {
NSLog(@"Is subtract");
}
if ([type isEqual:@"multiply"]) {
var1.textAlignment = NSTextAlignmentRight;
var1.frame = CGRectMake(40.0f, 70.0f, var1.frame.size.width,var1.frame.size.height);
var2.frame = CGRectMake(145.0f, 70.0f, var2.frame.size.width,var2.frame.size.height);
[UIView animateWithDuration:.25f animations:^{
add.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
add.alpha=0.0;
multiply.transform = CGAffineTransformMakeScale(1.5f, 1.5f);
multiply.alpha=0.0;
divide.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
divide.alpha=0.0;
circle.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
circle.alpha=0.0;
subtract.alpha=0.0;
var1.frame = CGRectMake(0.0f, 20.0f, var1.frame.size.width,var1.frame.size.height);
var2.frame = CGRectMake(185.0f, 20.0f, var2.frame.size.width,var2.frame.size.height);
signcircle.frame = CGRectMake(145.0f, 30.0f, signcircle.frame.size.width,signcircle.frame.size.height);
sign.frame = CGRectMake(152.0f, 26.5f, sign.frame.size.width,sign.frame.size.height);
result.frame = CGRectMake(8.0f, 100.0f, result.frame.size.width,result.frame.size.height);
signcircle.alpha=1.0;
sign.alpha=1.0;
var2.alpha=1.0;
result.alpha=1.0;
one.alpha=1.0;
onebutton.alpha=1.0;
twobutton.alpha=1.0;
two.alpha=1.0;
three.alpha=1.0;
threebutton.alpha=1.0;
fourbutton.alpha=1.0;
four.alpha=1.0;
sixbutton.alpha=1.0;
six.alpha=1.0;
five.alpha=1.0;
fivebutton.alpha=1.0;;
sevenbutton.alpha=1.0;
seven.alpha=1.0;
eightbutton.alpha=1.0;
eight.alpha=1.0;
ninebutton.alpha=1.0;
nine.alpha=1.0;
zerobutton.alpha=1.0;
zero.alpha=1.0;
decimalbutton.alpha=1.0;
decimal.alpha=1.0;
equalsbutton.alpha=1.0;
equals.alpha=1.0;
}];
[self.view.layer removeAllAnimations];
[self functionToBeCalled:self];
}
if ([type isEqual:@"divide"]) {
NSLog(@"Is divide");
}
}
在這種情況下它導致 「VAR1」 和 「VAR2」(UILabel
的)不向上移動。
我明白它的困惑,我到處尋找並找不到類似的問題,所以這是我最後的手段,如果任何人有任何解決方案或技巧,將不勝感激。