我使用在UIBlurEffect 8中实现的iOS轻松模糊屏幕。然而,我遇到了一个问题,因为我不知道如何将这个模糊效果变成动画,而不是即时效果。
我试过用这个,但没用:
[UIView animateWithDuration:3 animations:^
{
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.view.frame;
[self.view addSubview:visualEffectView];
}];虽然它确实显示了效果,但它在3秒内没有动画。
发布于 2014-10-29 18:05:54
你没有看到任何动画,因为你没有做任何动画。UIView动画依赖于使用现有视图的可动画属性。您没有激活任何属性:您只是在调用addSubview:。
发布于 2018-01-12 11:10:36
首先定义UIVisualEffectView()并定义其框架,然后可以有效地动画blurView:
let blurView = UIVisualEffectView()
blurView.frame = self.view.bounds
UIView.animate(withDuration: 0.5) {
blurView.effect = UIBlurEffect(style: .light)
}https://stackoverflow.com/questions/26637541
复制相似问题