PresentModalViewController()でUIViewControllerをモーダル表示していますが、
以下の画像の通り、背景が黒くなってしまいます。
下の3つを設定して透過すると思いましたが、黒いままでした。何か間違っているでしょうか?
ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; // OverFullScreenでも変化なし View.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); // UIColor.Clearでも変化なし View.Opaque = false; // trueでも変化なし
▼ViewController.cs
c#
1 public partial class ViewController : UIViewController 2 { 3 public ViewController (IntPtr handle) : base (handle) 4 { 5 } 6 7 public override void ViewDidLoad () 8 { 9 base.ViewDidLoad (); 10 11 UIButton button = new UIButton() 12 { 13 Bounds = new CGRect(0, 0, 200, 200), 14 BackgroundColor = UIColor.Green 15 }; 16 button.Center = View.Center; 17 button.TouchUpInside += OnGreenClicked; 18 View.AddSubview(button); 19 } 20 21 private void OnGreenClicked(object sender, EventArgs e) 22 { 23 this.PresentModalViewController(new ModalViewController(), true); 24 } 25 26 public override void DidReceiveMemoryWarning () 27 { 28 base.DidReceiveMemoryWarning (); 29 } 30 }
▼ModalViewController.cs
c#
1 class ModalViewController : UIViewController 2 { 3 public ModalViewController() 4 { 5 } 6 7 public override void ViewDidLoad() 8 { 9 base.ViewDidLoad(); 10 11 ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; // OverFullScreenでも変化なし 12 ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; 13 View.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); // UIColor.Clearでも変化なし 14 View.Opaque = false; // trueでも変化なし 15 16 UIButton button = new UIButton() 17 { 18 Bounds = new CGRect(0, 0, 200, 200), 19 BackgroundColor = UIColor.Blue 20 }; 21 button.Center = View.Center; 22 button.TouchUpInside += OnBlueClicked; 23 View.AddSubview(button); 24 } 25 26 private void OnBlueClicked(object sender, EventArgs e) 27 { 28 this.DismissModalViewController(true); 29 } 30 }
◆環境
▼Windows 10
Visual Studio Community 2017 Version 15.9.11
Xamarin 4.12.3.83
Xamarin.iOS and Xamarin.Mac SDK 12.4.0.64
▼Mac mini(Late 2014)
macOS Majave 10.14.4
Xcode 10.2.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/15 05:15