使用 Xamarin.Forms 向图像添加叠加颜色 [英] Add overlay color to an image using Xamarin.Forms

查看:22
本文介绍了使用 Xamarin.Forms 向图像添加叠加颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中添加一些图标,尤其是在使用自定义单元格的列表视图中,并指定要呈现的颜色.我不想在 Photoshop 中编辑每个图像;我想在运行时应用叠加颜色.

这可以通过自定义渲染器实现吗?

解决方案

不,通过 Xamarin.Forms 中提供的标准 Image 类是不可能的.

但是你可以使用这个家伙创建的这个惊人的 IconView 自定义渲染器.我一直在使用它,真是太棒了.

I'd like to add some icons in my app especially in listviews using custom cell and specify the color to be rendered. I don't want to edit each image in Photoshop; I want to apply an overlay color at runtime.

Is that possible with a custom renderer?

解决方案

No it is not possible through standard Image class provided in Xamarin.Forms.

But you can use this amazing IconView custom renderer created by this guy. I use it all the time it is amazing.

IconView for Xamarin Forms

Usage

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="IconApp.MyPage"
             xmlns:controls="clr-namespace:IconApp;assembly=IconApp">
  <controls:IconView Source="monkey"
                     Foreground="Red"
                     WidthRequest="100"
                     HeightRequest="100"
                     HorizontalOptions="Center"
                     VerticalOptions="Center" />
</ContentPage>

Just specify the Foreground="Red" property color

这篇关于使用 Xamarin.Forms 向图像添加叠加颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆