Bug 56731 - When using a custom iOS ViewRenderer, background colors are broken.
Summary: When using a custom iOS ViewRenderer, background colors are broken.
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.4
Hardware: Macintosh Mac OS
: Normal minor
Target Milestone: ---
Assignee: Bugzilla
URL: https://drive.google.com/file/d/0B7Z1...
Depends on:
Blocks:
 
Reported: 2017-05-22 18:00 UTC by njangula
Modified: 2017-06-06 01:58 UTC (History)
3 users (show)

Tags: viewcell backgroundcolor ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 56731 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description njangula 2017-05-22 18:00:50 UTC
I created a custom iOS ViewRenderer, and exported it as normal.  However, even without overriding any functions, I noticed the background colors of some of my controls was transparent.  I overrode SetBackgroundColor, and noticed that even after call base.SetBackgroundColor, this.BackgroundColor was still rbga 0000.  A simple temporary fix that worked for our project:


protected override void SetBackgroundColor(Color color)
{
    var uiColor = newUIColor((float)color.R, (float)color.G, (float)color.B, (float)color.A);
    BackgroundColor = uiColor;
}


Sidenote, but perhaps relevant:  Maybe I'm understanding custom renderers wrong, but when setting a breakpoint in this method, should this.Control be null every time?  Other renderers use this.Control to do the job, but it's null in this one.
Comment 1 Paul DiPietro [MSFT] 2017-06-01 17:22:44 UTC
Hi, can you upload a reproduction to better illustrate your issue and what controls you're using? Thanks.
Comment 2 njangula 2017-06-01 18:59:32 UTC
It wouldn't let me upload a sample project, so here's a link to an upload:  https://drive.google.com/file/d/0B7Z1N6KsnLHoMDZoVzQtTXItaDA/view?usp=sharing

Check out the xml comments and #warnings
Comment 3 Paul DiPietro [MSFT] 2017-06-04 17:24:21 UTC
This appears to be because the view in particular you're having issues with is a ViewCell which has its own renderer, and something in between is causing the loss of color being applied. I'll set this as a confirmed bug for now just until it can get further investigation. Your reproduction was probably too large, so a clean and deletion of the packages and bin/obj folders would likely resolve that issue.