使用Xamarin.Forms为图像添加叠加颜色 [英] Add overlay color to an image using Xamarin.Forms
本文介绍了使用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.
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屋!
查看全文