Align background color handling in iOS with Android implementation (#546)
This commit is contained in:
Родитель
0c2e2e7336
Коммит
0eacf93058
|
@ -21,7 +21,7 @@ namespace OxyPlot.Xamarin.Forms
|
||||||
/// <returns>The converted color.</returns>
|
/// <returns>The converted color.</returns>
|
||||||
public static global::Xamarin.Forms.Color ToXamarinForms(this OxyColor c)
|
public static global::Xamarin.Forms.Color ToXamarinForms(this OxyColor c)
|
||||||
{
|
{
|
||||||
return new global::Xamarin.Forms.Color(c.R / 255d, c.G / 255d, c.B, c.A / 255d);
|
return global::Xamarin.Forms.Color.FromRgba(c.R, c.G, c.B, c.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -31,7 +31,7 @@ namespace OxyPlot.Xamarin.Forms
|
||||||
/// <returns>The converted color.</returns>
|
/// <returns>The converted color.</returns>
|
||||||
public static OxyColor ToOxyColor(this global::Xamarin.Forms.Color c)
|
public static OxyColor ToOxyColor(this global::Xamarin.Forms.Color c)
|
||||||
{
|
{
|
||||||
return OxyColor.FromArgb((byte)(c.R * 255), (byte)(c.G * 255), (byte)(c.B * 255), (byte)(c.A * 255));
|
return OxyColor.FromArgb((byte)(c.A * 255), (byte)(c.R * 255), (byte)(c.G * 255), (byte)(c.B * 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,16 +246,6 @@ namespace OxyPlot.Xamarin.iOS
|
||||||
((IPlotModel)actualModel).Update(updateData);
|
((IPlotModel)actualModel).Update(updateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actualModel != null && !actualModel.Background.IsUndefined())
|
|
||||||
{
|
|
||||||
this.BackgroundColor = actualModel.Background.ToUIColor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use white as default background color
|
|
||||||
this.BackgroundColor = UIColor.White;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.SetNeedsDisplay();
|
this.SetNeedsDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,11 +292,19 @@ namespace OxyPlot.Xamarin.iOS
|
||||||
/// <param name="rect">The rectangle to draw.</param>
|
/// <param name="rect">The rectangle to draw.</param>
|
||||||
public override void Draw(CoreGraphics.CGRect rect)
|
public override void Draw(CoreGraphics.CGRect rect)
|
||||||
{
|
{
|
||||||
if (this.model != null)
|
var actualModel = (IPlotModel)this.model;
|
||||||
|
if (actualModel != null)
|
||||||
{
|
{
|
||||||
using (var renderer = new CoreGraphicsRenderContext(UIGraphics.GetCurrentContext()))
|
var context = UIGraphics.GetCurrentContext ();
|
||||||
|
using (var renderer = new CoreGraphicsRenderContext(context))
|
||||||
{
|
{
|
||||||
((IPlotModel)this.model).Render(renderer, rect.Width, rect.Height);
|
if (actualModel.Background.IsVisible())
|
||||||
|
{
|
||||||
|
context.SetFillColor (actualModel.Background.ToCGColor ());
|
||||||
|
context.FillRect (rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
actualModel.Render(renderer, rect.Width, rect.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче