6 iphone cocoa-touch objective-c uikit ios
我的iphone屏幕上有一个刷新按钮,用于刷新当前视图中的表格.
屏幕刷新很漂亮,但是有一种方法可以使屏幕变暗然后在桌子刷新后再次变亮吗?
tea*_*bot 15
您可以在想要调暗的视图上放置一个带有黑色背景的非不透明视图.默认情况下,它的alpha值为0,因此是透明的.然后,您可以使用UIView动画将黑色视图alpha设置为0到0.5(比方说)然后再返回.
注意:下面的代码尚未经过测试,但我使用了类似的实现相同的效果.
...
dimView.alpha = 0.0f;
[UIView beginAnimations@"fade" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationRepeatAutoreverses:YES];
dimView.alpha = 0.5f;
[UIView commitAnimations];
...
}
- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
dimView.alpha = 0.0f;
}
Run Code Online (Sandbox Code Playgroud)