我无法为UIView的边框颜色制作动画

Ser*_*gio 1 core-animation objective-c

我尝试为UIView边框制作淡入/淡出效果,但它不起作用.当尝试对背景颜色执行以下效果时,它可以完美地工作.这是我开发的代码:

[UIView animateWithDuration:3.0f 
             animations:^ {

                 [UIView beginAnimations:nil context:nil];
                 [UIView setAnimationDuration:0.5];
                 self.layer.borderColor = [[UIColor redColor] CGColor];
                 self.layer.borderWidth = 1.5f;
                 [UIView commitAnimations];
             } 
             completion:^(BOOL finished){

                 [UIView beginAnimations:nil context:nil];
                 [UIView setAnimationDuration:0.8];
                 self.layer.borderColor = [[UIColor whiteColor] CGColor];
                 self.layer.borderWidth = 1.5f;
                 [UIView commitAnimations];
             }];
Run Code Online (Sandbox Code Playgroud)

Rob*_*ins 5

根据我的问题的答案,您无法在UIView块中设置CALayer属性的动画.