如何在Xamarin标签或图片中添加波纹效果?

问题描述 投票:1回答:1

我正在寻找在标签文本或图像中实现波纹效果,那么如何在任何标签或图像中添加波纹效果?

xamarin xamarin.forms xamarin.android xamarin.ios
1个回答
2
投票

你可以使用软件包 触摸视图 来自纽吉特

将nuget包添加到你的Xamarin.Forms.netStandardPCL项目和你的特定平台项目(iOS和Android)中。

iOS: 添加TouchViewRenderer.Initialize()行到你的AppDelegate中(从链接器中保留)

using TouchEffect.iOS;
namespace YourApp.iOS
{
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            TouchViewRenderer.Initialize();
            LoadApplication(new App());
            return base.FinishedLaunching(app, options);
        }
    }
}

在xaml中

<?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:local="clr-namespace:YourApp"
             xmlns:touch="clr-namespace:TouchEffect;assembly=TouchEffect"
             x:Class="App11.MainPage">

    <StackLayout>
        <touch:TouchView
            RegularBackgroundColor="LightGray"
            PressedBackgroundColor="Gray"
            PressedOpacity="1"       

            PressedAnimationDuration="100"
            RegularAnimationDuration="100"
            Padding="10, 5"
            VerticalOptions="CenterAndExpand"
            HorizontalOptions="CenterAndExpand"
            Completed="Handle_TouchCompleted"
           >

            <Label Text="Click Me" 
                   TextColor="Black" 
                   FontSize="30"/>

        </touch:TouchView>
    </StackLayout>

</ContentPage>

暗中

private void Handle_TouchCompleted(TouchEffect.TouchView sender, TouchEffect.EventArgs.TouchCompletedEventArgs args)
 {
    // do something you want        
 }

0
投票

你可以使用 TouchEffect 图书馆从 AndreiMisiukevich.了解更多信息。https://github.com/AndreiMisiukevich/TouchEffect

还有另一个库也可以用. https://github.com/mrxten/XamEffects

两者都有完善的文档。

© www.soinside.com 2019 - 2024. All rights reserved.