2017-06-20 25 views
1

コントローラからモーダルビューを表示しようとしていますが、テキストフィールドを除くすべての背景をhereのように黒く表示します。 (the intended modalスウィフトのモーダルビューの背景が黒く表示された後に黒く表示されます

これは、ここで答え

は、第1のコントローラで私のaddEvent方法であるしかし、私はすでに最も類似の質問が提起コードを実装している、かなり一般的な問題のようです:

@IBAction func addEvent(_ sender: Any) { 
    let newEventViewController = NewEventViewController() 
    newEventViewController.view.backgroundColor = UIColor.clear 
    newEventViewController.view.isOpaque = false 
    navigationController?.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext 
    navigationController?.present(newEventViewController, animated: true, completion: nil) 
} 

私が紛失していることを理解する助けがあれば幸いです。違いがある場合は、ストーリーボードではなく、個別のxibファイルを使用してアプリケーションを作成しています。必要に応じていないが、私はむしろ、このようなナビゲーションコントローラよりも自己から提示する。また

newEventViewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext 

:あなたはこのようnewEventControllerのmodalPresentationStyleないnavigationControllerを設定する必要が

+0

ことができますより多くの情報を提供しますか?あなたは自己を試しましたか?現在...?またself.modalPresentationStyleを設定する 通常isOpaqueとbackgroundColorはviewDidLoadに設定する必要がありますが、私はあなたの問題だとは思わないでください – Jeremie

答えて

5

self.present(newEventViewController, animated: true, completion: nil) 
+0

これは予期したとおりに動作します! –

+0

ターゲットを叩く..ありがとう。 @ChristopherKonopka - これを受け入れられた回答としてマークしてください。 – GKK

関連する問題