ios - iPad 上的模态表单在 Swift 中透明吗?

标签 ios swift storyboard modalviewcontroller

我想制作一个表单,以模态方式呈现,部分透明,类似于音量表或控制中心在 iOS 7+ 中的部分透明方式。

我正在使用 XCode 6.3.2、Swift 1.2 进行编程,它适用于 iOS 8 平台 (iPad)。

我尝试了以下方法:

Setting the ViewController's alpha value in Storyboard to 0.5

背景颜色结果显得更暗,但不透明,文字显得微弱。

Setting background color in Storyboard to "Clear Color"

背景颜色看起来更暗,没有注意到更暗的文字。

Setting background color to a color with 30% transparency

同上。

De - selecting Clears Graphics Content

最终结果没有明显变化。

澄清一下,我想要在 iPad 上使用部分透明的模态视图,而不是较暗的背景。

有什么方法可以在 Swift 或 Storyboard 中做到这一点?

最佳答案

Rocket101,这是我用来实现类似效果的代码。它在 Objective C 中,但您应该能够轻松翻译它。 在登录期间,我用“coverView”阻止了我当前的 View ,它显示了一个模糊的 Logo 。在您的情况下,您不会包含“backgroundImage”。 这是我创建模糊效果的方法。

  UIView *coverView = [[UIView alloc] init];
  coverView.frame = self.tabBarController.view.bounds;
  UIImage *backgroundImage = [UIImage imageNamed:@"SomeBackgroundImage"];
  UIImageView *backgroundView = [[UIImageView alloc] initWithImage:backgroundImage];
  backgroundView.frame = self.tabBarController.view.bounds;
  UIVisualEffect *blurEffect;
  blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
  UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
  effectView.frame = self.tabBarController.view.bounds;
  effectView.alpha = 0.8;
  [coverView addSubview:backgroundView];
  [coverView addSubview:effectView];
  [coverView sendSubviewToBack:effectView];
  [coverView sendSubviewToBack:backgroundView];
  [theView addSubview:coverView];

关于ios - iPad 上的模态表单在 Swift 中透明吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32208830/

相关文章:

ios - xcode中标签栏 Controller View 的第一个 View

swift - 如果达到一定分数则添加 Sprite

wpf - 找不到 EventTrigger.SourceName

swift - 无法使用 Storyboard将窗口连接到 IBOutlet

ios - 在 iOS UITest 中获取当前 GPS 位置

iphone - UIView透明渐变

swift - 如何在 swift 中调试此信息(SIGTRAP #0)?

ios - 修复静态 tableviewcontroller xcode 8 中 Storyboard 中的所有警告

ios - block 中的 WeakSelf

ios - 遍历对象数组并添加到数组数组