我已经创建了UITextView文本作为背景图像的蒙版,以便使用iOS 8中引入的 maskview 函数动态地为背后的图像着色文本。
但是我想在屏蔽操作期间添加淡入淡出效果。
换句话说,如何在屏蔽操作中添加过渡动画?
我实际上使用了下面的代码,但无法将动画集成到其中。
self.view.maskView = self.textView
答案 0 :(得分:0)
您应该将textView alpha设置为0.0,将其设置为maskView,然后制作一个将alpha设置为1.0的动画。
self.textView.alpha = 0;
self.view.maskView = self.textView;
[UIView animateWithDuration:0.5 animations:^{
maskView.alpha = 1.0;
}];
答案 1 :(得分:0)
在您的视图中使用[UIView transitionWithView:"yourView"
duration:0.3f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
//animation code
} completion:nil];
动画属性,它将为您提供淡入淡出效果
materialize-css
答案 2 :(得分:0)
我已经结合了这里所说的两个解决方案,以实现我正在寻找但无法摆脱self.view.maskView = self.textView赋值后发生的flash效果
UIView.transitionWithView(self.textView, duration: 1.0, options:UIViewAnimationOptions.TransitionFlipFromTop, animations: {
self.view.maskView = self.textView
self.view.maskView.alpha = 0.0
self.view.maskView.alpha = 1.0
}, completion: nil
)