模态呈现的视图控制器的透明背景 [英] Transparent background for modally presented viewcontroller

查看:32
本文介绍了模态呈现的视图控制器的透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Parse &解析界面.我希望我的 PFLoginViewController 子类具有透明背景.以后,我想在背景上放一个模糊的视图.

I am using Parse & ParseUI. I want my PFLoginViewController subclass to have a transparent background. In the future, I want to lay a blurred view over the background.

但是.... PFLoginViewController 的动画输入完成后,背景变为黑色...而动画期间背景是透明的.

But.... Once the animate-in of the PFLoginViewController is done, the background turns black... Whilst during the animation the background was transparent.

func presentLogin() {
    var loginViewController = LoginViewController()
    var signupViewController = SignUpViewController()

    loginViewController.fields = .UsernameAndPassword | .LogInButton | .PasswordForgotten | .SignUpButton | PFLogInFields.DismissButton
    signupViewController.fields = .UsernameAndPassword | .Email | .DismissButton | .SignUpButton
    loginViewController.delegate = self
    loginViewController.logInView.backgroundColor = UIColor.clearColor()
    loginViewController.logInView.opaque = false
    signupViewController.delegate = self

    loginViewController.signUpController = signupViewController

    self.presentViewController(loginViewController, animated: true) { () -> Void in
        //
    }
}

我的 logincontroller 使用的子类:

My logincontroller's used subclass:

class LoginViewController: PFLogInViewController {

    @IBOutlet weak var _nmcLogoLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        let userName = SettingsManager.userName
        let password = SettingsManager.password

        self.logInView.usernameField.text = userName
        self.logInView.passwordField.text = password

        NSBundle.mainBundle().loadNibNamed("LoginViewBranding", owner: self, options: nil)[0] as? UIView

        self.logInView.logo = _nmcLogoLabel

    }

}

如何让它透明?

附言将clearColor应用到子类中的backgroundColor没有区别

P.s. Applying the clearColor to the backgroundColor in the subclass makes no difference

推荐答案

已修复.

问题是 presentViewController 没有保留我正在覆盖的视图.

The problem was that presentViewController does not keep the view that I was covering.

viewController.modalPresentationStyle = .overCurrentContext

成功了.

这篇关于模态呈现的视图控制器的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆