相关疑难解决方法(0)

如何设置UILabel的背景颜色动画?

这看起来应该可以,但不是.颜色立刻变为绿色.

self.labelCorrection.backgroundColor = [UIColor whiteColor];
[UIView animateWithDuration:2.0 animations:^{
    self.labelCorrection.backgroundColor = [UIColor greenColor];
}];
Run Code Online (Sandbox Code Playgroud)

iphone core-animation ios

73
推荐指数
4
解决办法
5万
查看次数

如何在ios sdk中使用动画增加和减少图像alpha值?

在这段代码中我使用的是动画.但是我一次也需要更改图像的alpha值.

-(void)animation
{
    CGPoint point = CGPointMake(imgView.frame.origin.x, imgView.frame.origin.y);
    imgView.layer.position = point;
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position.x"];
    anim.fromValue  = [NSValue valueWithCGPoint:point];
    anim.toValue    = [NSValue valueWithCGPoint:CGPointMake(point.x + 50, point.y)];
    anim.duration   = 10.0f;
    anim.repeatCount =1;
    anim.removedOnCompletion = YES;

    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

    [imgView.layer addAnimation:anim forKey:@"position.x"];
    imgView.layer.position = point;
}
Run Code Online (Sandbox Code Playgroud)

iphone ios

5
推荐指数
1
解决办法
3317
查看次数

UIView.animateWithDuration没有动画

我的ViewController viewDidLoad函数中的UIView.animateWithDuration调用没有动画.立即调用完成块.println输出显示'completion true'.viewDidLoad函数是否放置了我的启动动画的错误位置?非常感谢任何提示.

class ViewController: UIViewController {
    @IBOutlet var beatIndicator:UIView?

    override func viewDidLoad() {
        super.viewDidLoad()

        if let led = beatIndicator? {
            led.alpha = 1.0
            led.frame = CGRectMake(20, 20, 30, 30)
            led.layer.cornerRadius = 15

            UIView.animateWithDuration(3.0, animations:{
                led.alpha = 0.5
                led.frame = CGRectMake(25, 25, 20, 20)
                led.layer.cornerRadius = 10
            }, completion:{(value: Bool) in
                println("completion \(value)")
            })
        }

        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

animatewithduration swift ios8 xcode6.0.1

2
推荐指数
1
解决办法
2065
查看次数