微信公衆號:Dotnet9,網站:Dotnet9,問題或建議,請網站留言;
若是您以爲Dotnet9對您有幫助,歡迎讚揚。html
內容目錄android
彈出動畫
ios
主窗口彈出登陸或者其餘小窗口時使用git
建立名爲「App5」的Xamarin.Forms項目,添加Rg.Plugins.PopupNuget庫:彈出框由該插件提供,看下圖1.31M下載量,請放心使用。github
Rg.Plugins.PopupNuget插件
數個文件變更:微信
簡單的一個按鈕控件,點擊模擬觸發彈出登陸窗口app
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="App5.MainPage"> <StackLayout Spacing="18" VerticalOptions="Center"> <Button Clicked="ShowPopup" Text="彈出窗體" /> </StackLayout> </ContentPage>
後臺彈出登陸窗口學習
private void ShowPopup(object o, EventArgs e) { PopupNavigation.Instance.PushAsync(new LoginPage()); }
登陸窗口,引入彈出插件Rg.Plugins.Popup,設置彈出框動畫動畫
<?xml version="1.0" encoding="utf-8" ?> <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup" xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup" x:Class="App5.Views.LoginPage"> <pages:PopupPage.Animation> <animations:ScaleAnimation DurationIn="400" DurationOut="300" EasingIn="SinOut" EasingOut="SinIn" HasBackgroundAnimation="True" PositionIn="Center" PositionOut="Center" ScaleIn="1.2" ScaleOut="0.8" /> </pages:PopupPage.Animation> <Grid BackgroundColor="White" VerticalOptions="Center" Margin="30" HeightRequest="350"> <Grid.RowDefinitions> <RowDefinition Height="80"/> <RowDefinition Height="*"/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0,10,0,0"> <Label Text="選擇語言"/> <Image Source="down_arrow.png" Opacity="0.6" VerticalOptions="Start" Margin="0,3,0,0"/> </StackLayout> <Grid Grid.Row="1" Margin="20,0,20,0"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="50"/> <RowDefinition Height="50"/> <RowDefinition Height="Auto"/> <RowDefinition Height="40"/> <RowDefinition Height="40"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Image Source="person.png" HeightRequest="70" VerticalOptions="End"/> <Entry Grid.Row="1" Placeholder="帳號" PlaceholderColor="#bababa" FontSize="16"/> <Entry Grid.Row="2" Placeholder="密碼" PlaceholderColor="#bababa" FontSize="16"/> <Button Grid.Row="3" Text="登陸" BackgroundColor="#3897f0" TextColor="White" HeightRequest="50" VerticalOptions="Start"/> <Label Grid.Row="4" Text="沒有帳號?請聯繫管理員。" HorizontalOptions="Center" Margin="0,10,0,0" FontSize="12"/> </Grid> </Grid> </pages:PopupPage>
註冊彈出插件
註冊彈出插件
Houssem Dellai 大神的學習視頻:Popup in Xamarin Forms
文中代碼已經所有提供,參考Github源碼:Xamarin-Forms-Popup-Demo
除非註明,文章均由 Dotnet9 整理髮布,歡迎轉載。
轉載請註明本文地址:https://dotnet9.com/6829.html
歡迎掃描下方二維碼關注 Dotnet9 的微信公衆號,本站會及時推送最新技術文章