启动应用程序时我会UIAlert
提示输入密码,但我想在需要密码时隐藏视图控制器中的内容,特别是在applicationDidBecomeActive
. 有没有简单的方法来做到这一点?
提前致谢!
启动应用程序时我会UIAlert
提示输入密码,但我想在需要密码时隐藏视图控制器中的内容,特别是在applicationDidBecomeActive
. 有没有简单的方法来做到这一点?
提前致谢!
您可以通过在顶部放置一个对象(例如 UIImageView 甚至是简单的 UILabel)并在需要密码时将其 alpha 设置为 1.0 来实现。您甚至可以考虑应用 UIAnimation 来实现淡入/淡出效果,以获得更好的用户体验:
-(void)setupLabelForContentHiding{
CGRect rect = labelEmpty.frame; //UILabel
rect.origin.y = 0;
rect.origin.x = 0;
rect.size.width = self.view.frame.size.width;
rect.size.height = self.view.frame.size.height;
labelEmpty.frame = rect;
labelEmpty.alpha=0.0;
}
-(IBAction) hideContent:(id)sender{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelay:0.0];
labelEmpty.alpha = 1.0;
[UIView commitAnimations];
}