【发布时间】:2021-08-18 19:34:36
【问题描述】:
这就是我所说的:(取自 Elgato Control Center 应用程序)
iPhone
iPad
不胜感激,谢谢!
【问题讨论】:
标签: c# xamarin xamarin.forms
这就是我所说的:(取自 Elgato Control Center 应用程序)
iPhone
iPad
不胜感激,谢谢!
【问题讨论】:
标签: c# xamarin xamarin.forms
答案取决于您对术语的定义。
如果您认为仅使用 Xamarin.Forms 并使用已显示的本机弹出窗口,答案是否定的。
如果您可以使用一些非本地弹出窗口,那么您可以阅读 Wen xu Li 的答案(但我会说它不太符合您的要求)。
最后,Xamarin.Forms 建立在 Xamarin.iOS 之上,这样的事情是可能的。你可以访问 Xamarin.iOS 项目,从技术上讲你可以做到这一点。我认为这应该可以通过自定义渲染器实现。
【讨论】:
我用 Rg.Plugins.Popup 写了一个例子。
这里是 xaml 代码:
<pages:PopupPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
x:Class="App2.Page1">
<pages:PopupPage.Animation>
<animations:ScaleAnimation
PositionIn="Bottom"
PositionOut="Bottom"
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"/>
</pages:PopupPage.Animation>
<StackLayout
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand">
<Frame CornerRadius="20" HorizontalOptions="FillAndExpand" HeightRequest="200" >
<StackLayout>
<Label Text="This is popuppage"></Label>
<Button Text="close" Clicked="Button_Clicked" VerticalOptions="EndAndExpand"></Button>
</StackLayout>
</Frame>
</StackLayout>
</pages:PopupPage>
这是cs代码:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page1 : Rg.Plugins.Popup.Pages.PopupPage
{
public Page1()
{
InitializeComponent();
}
private async void Button_Clicked(object sender, EventArgs e)
{
await Navigation.PopPopupAsync();
}
}
在Android的MainActivity中添加:
Rg.Plugins.Popup.Popup.Init(this);
在IOS的AppDelegate中添加:
Rg.Plugins.Popup.Popup.Init();
这是运行截图:
【讨论】: