Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView不为alpha设置动画_Ios_Animation_Uiview - Fatal编程技术网

Ios UIView不为alpha设置动画

Ios UIView不为alpha设置动画,ios,animation,uiview,Ios,Animation,Uiview,我正在尝试为视图的alpha设置动画,但无法使其工作 self.transform = CGAffineTransformMakeScale(0.01, 0.01); [UIView animateWithDuration:1.5 animations:^{ self.alpha = 0; self.transform = CGAffineTransformIdentity; } completion:^(BOOL finished) { self.alpha = 1;

我正在尝试为视图的alpha设置动画,但无法使其工作

self.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:1.5 animations:^{
    self.alpha = 0;
    self.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
    self.alpha = 1;
}];
动画可以工作,但alpha在1处是静态的。不过,变换会正确设置动画。如果我删除设置转换只是为了测试它是否是由它引起的,什么也不会发生

我也尝试过重复动画,它会重复,但alpha始终为1:

[UIView animateWithDuration:1.5 delay:delay
  options:(UIViewAnimationOptionRepeat
         | UIViewAnimationOptionCurveEaseInOut
         | UIViewAnimationOptionTransitionNone) animations:^{
    self.alpha = 0;
    self.transform = CGAffineTransformIdentity;
  } completion:^(BOOL finished) {
    if(finished){
        self.alpha = 1;
    }
  }];

为什么会这样?

我找到了解决办法。它有多个问题。首先,这个观点是不透明的。我已将“不透明”设置为“否”,但什么也没发生。然后我意识到我从alpha=0开始,我也改变了这一点,它开始以我想要的方式制作动画


汉普斯·尼尔森在这里的评论值得赞扬:

@picciano没有得到回答。问题下的一条评论解决了我的问题,而不是它的答案。问题和解决方案是相同的,这就是为什么我将其标记为重复的原因。继续回答另一个问题,并获得积分。