闪烁隐藏并使用块
我有方法:
- (void)blinkView:(UIView *)view { view.layer.opacity = 0.0f; view.hidden = NO; [UIView beginAnimations:@"Blinking" context:nil]; [UIView setAnimationRepeatCount:1.0]; [UIView setAnimationDuration:0.6f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; view.layer.opacity = 1.0f; [UIView commitAnimations]; }
我怎样才能写这个代码块,以及如何实现具有相反效果的方法(隐藏与闪烁uiview)?
[UIView transitionWithView: view duration:0.6f options:UIViewAnimationOptionCurveEaseInOut animations:^{ view.layer.opacity = 1.0f; } completion:NULL];
要么
[UIView transitionWithView: view duration:0.6f options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{ view.layer.opacity = 1.0f; } completion:NULL];
您可以通过recursion调用animation块来设置重复次数(请参见此处 )。
希望它会帮助你。
你可以使用UIView的setAnimationDelegate:和setAnimationDidStopSelector:
[UIView beginAnimations:@"Blinking" context:nil]; [UIView setAnimationRepeatCount:1.0]; [UIView setAnimationDuration:0.6f]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; view.layer.opacity = 1.0f; [UIView commitAnimations]; - (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { // add your final code here : you can give new animation effect here. }
或者尝试animateWithDuration (仅适用于iOS 4或更高版本)
[UIView animateWithDuration:0.6f animations:^{ view.layer.opacity = 1.0f; } completion:^(BOOL completed){ // add your final code here : you can give new animation effect here. } ];
- CAReplicatorLayer背后的魔法是什么?
- 在Mac OS X 10.7 Lion上使用Core Animation进行AVFoundation问题
- iOS – 从底部填充UIBezierpath的animation
- 使用Core Animation完成自定义animation – 性能
- Autolayout,UIDynamics和animation
- 我如何使通过-addSublayer添加的UI元素:响应触摸事件?
- drawViewHierarchyInRect:afterScreenUpdates:延迟其他animation
- 视网膜显示核心graphics的字体质量
- 停止使用RepeatsForever – Sprite Kit的SKAction