我正在使用以下内容显示模式视图
[self presentModalViewController:controller animated:YES];
当视图在屏幕上移动时,根据创建它的xib文件中的设置,它是透明的,但一旦它填满屏幕,它就会变得不透明。
有没有保持视图透明的方法?
我怀疑它放在上面的视图没有被渲染,而不是模式视图变得不透明。
发布于 2009-02-25 21:22:55
您的视图仍然是透明的,但是一旦您的模态控制器位于堆栈的顶部,它后面的视图就会被隐藏(就像任何最顶层的视图控制器一样)。解决方案是自己手动设置视图动画;然后,后台的viewController将不会被隐藏(因为您不会“离开”它)。
发布于 2013-01-20 00:19:34
我需要做的是让它工作:
self.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
发布于 2009-08-30 15:55:15
对于那些想看一些代码的人,下面是我在透明视图的控制器中添加的内容:
// Add this view to superview, and slide it in from the bottom
- (void)presentWithSuperview:(UIView *)superview {
// Set initial location at bottom of superview
CGRect frame = self.view.frame;
frame.origin = CGPointMake(0.0, superview.bounds.size.height);
self.view.frame = frame;
[superview addSubview:self.view];
// Animate to new location
[UIView beginAnimations:@"presentWithSuperview" context:nil];
frame.origin = CGPointZero;
self.view.frame = frame;
[UIView commitAnimations];
}
// Method called when removeFromSuperviewWithAnimation's animation completes
- (void)animationDidStop:(NSString *)animationID
finished:(NSNumber *)finished
context:(void *)context {
if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) {
[self.view removeFromSuperview];
}
}
// Slide this view to bottom of superview, then remove from superview
- (void)removeFromSuperviewWithAnimation {
[UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil];
// Set delegate and selector to remove from superview when animation completes
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
// Move this view to bottom of superview
CGRect frame = self.view.frame;
frame.origin = CGPointMake(0.0, self.view.superview.bounds.size.height);
self.view.frame = frame;
[UIView commitAnimations];
}
https://stackoverflow.com/questions/587681
复制相似问题