简体   繁体   English

如何在 iOS 中使用 Material Designs“标准”底页?

[英]How to use Material Designs “Standard” bottomsheet in iOS?

I am trying to use Googles bottomsheet in an iOS app (Xamarin, which means it's written in C#).我正在尝试在 iOS 应用程序(Xamarin,这意味着它是用 C# 编写的)中使用 Google 的底页。 I've managed to use the "modal" variant, which dims the view behind it when it appears, but what I need is a bottomsheet that works as the one in the Google Maps app - allowing manipulation of both the area "below" the bottomsheet, as well as the content of the bottomsheet itself.我设法使用了“模态”变体,当它出现时它会使后面的视图变暗,但我需要的是一个底页,它可以作为谷歌地图应用程序中的底页 - 允许操纵“下方”的两个区域底页,以及底页本身的内容。

I've gotten a nuGet which contains a bunch of Material Design components (Xamarin.iOS.MaterialComponents), but I haven't been able to find any documentation saying how the "clickthrough" bottomsheet can be achieved.我得到了一个 nuGet,其中包含一堆材料设计组件(Xamarin.iOS.MaterialComponents),但我找不到任何说明如何实现“点击”底页的文档。 When making the (Xamarin) Android version of this app, I've managed to achieve a "clickthrough" bottomsheet - but in Android this comes in the form of something called a BottomSheetBehavior, which is attached to a child of a CoordinatorLayout.在制作此应用程序的(Xamarin)Android 版本时,我设法实现了“点击”底页 - 但在 Android 中,这以称为 BottomSheetBehavior 的形式出现,它附加到 CoordinatorLayout 的子项。 -This has me stumped, as there is (AFAIK) no corresponding layout-construct in iOS. - 这让我很难过,因为(AFAIK)在 iOS 中没有相应的布局结构。

This piece of code constructs a new viewController with some content, and displays it in a bottomsheet which slides up above the current view.这段代码构造了一个包含一些内容的新 viewController,并将其显示在一个底部表单中,该底部表单向上滑动到当前视图上方。 -All very well, but does anybody have any idea of how to make the background view "manipulable"? - 一切都很好,但是有人知道如何使背景视图“可操作”吗?

UIViewController content = new UIViewController();
content.View.Frame = new CoreGraphics.CGRect(0, 0, 200, 200);
content.View.BackgroundColor = UIColor.Blue;
Button b = new Button();
b.Frame = new CoreGraphics.CGRect(0, 0, 100, 20);
b.SetTitle("A Button appears!", UIControlState.Normal);
content.Add(b);

BottomSheetController bs = new BottomSheetController(content);         
bs.PreferredContentSize = new CoreGraphics.CGSize(300, 300);
PresentViewController(bs,true,null);

Thanks for reading: :)谢谢阅读: :)

You can use the UIAlertController for this if I am not wrong如果我没记错的话,你可以使用UIAlertController

All you have to do is something like this:你所要做的就是这样的:

var alert = UIAlertController.Create("Option!", "Option!?", UIAlertControllerStyle.ActionSheet);

And then just present it然后只是呈现它

PresentViewController (alert, animated: true, completionHandler: null);

For more information check the microsoft docs,有关更多信息,请查看 microsoft 文档,

Good luck.祝你好运。

Feel free to get back if you have queries如果您有任何疑问,请随时回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM