iPad 上的模态形式 sheet 在 Swift 中透明?
Modal form sheet on iPad transparent in Swift?
我想制作一个表单 sheet,以模态方式呈现,部分透明,类似于 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" 阻止了我当前的视图,它显示了一个模糊的徽标。在您的情况下,您不会包括 "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];
我想制作一个表单 sheet,以模态方式呈现,部分透明,类似于 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" 阻止了我当前的视图,它显示了一个模糊的徽标。在您的情况下,您不会包括 "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];