Nic,

On 2 February 2013 10:59, Nic Wise <n...@fastchicken.co.nz> wrote:
> Hi
>
> I tried running your code yesterday (this has been sitting in my
> "things to look into" since you posted it, I just had servers down in
> the day job, so I didn't have time to look into it)
>
> Glad you got it working!

Me too :)

Have a nice day,

Guido

>
> Nic
>
> On 1 February 2013 20:09, Guido Van Hoecke <gui...@gmail.com> wrote:
>> Hi,
>>
>> I found a way to get around this problem and want to share it.
>>
>> In the ViewWillAppear I now create a dummy RootElement with an empty
>> section. That ensures that the Root.TableView as well as
>> Root.TableView.BackgroundView do exist. I then set the BackgroundView to
>> null, and set the desired BackgroundColor.
>>
>> And then I create the real RootElement, ahter the UITableView settings
>> heave been done.
>>
>> Far from elegant, but it works for Plain as well as Grouped
>> UITableViewStyles.
>>
>>
>> Guido.
>>
>> On 30 January 2013 23:24, Guido Van Hoecke <gui...@gmail.com> wrote:
>>> Hi,
>>>
>>> I want to use gradient backgrounds for my tableview cells
>>> (based upon MonoTouch.Dialog StyledStringElements), and I want to
>>> specify the BackgroundColor of the UITableViews.
>>>
>>> After quite some searching and reading I came up with an approach that
>>> builds on two distinct aspects:
>>>
>>> 1. Nullify the TableView.BackgroundView and set the
>>> TableView.BackgroundColor to the desired color. This is the color that
>>> shows in the border around Grouped tableview cells.
>>>
>>> 2. Set the BackgroundColor as UIColorFromPatternImage(patternImage) for
>>> all Elements in the UITableView.
>>>
>>> My apps allow color selection by the user, so the pattern image is to be
>>> created dynamically (i.e. for the initial default color and whenever the
>>> user chooses a different color).
>>>
>>> 3. So here's how I create the gradient image:
>>>
>>> 3.1. Create a CAGradientLayer using White and the user specified color
>>>
>>> 3.2. Create a tiny (44x44) view, set its BackgroundColor to Clear, and
>>> insert the above gradientLayer as layer 0 using InsertSublLayer.
>>>
>>> 3.3. I then render the view in the current context and retrieve it as a
>>> UIImage file to be used by step 2 above, i.e. as patternImage.
>>>
>>> I created a one source demo project demonstrating these techniques. Feel
>>> free to get it at https://gist.github.com/4677718. Create an empty
>>> project and replace Main.cs by the Main.cs file from the gist.
>>> It works as desired, and you can change it to use UITableViewStyle.Plain
>>> rather than Grouped. It just works.
>>>
>>> So here's my problem. I use these techniques in 4 projects for all
>>> DialogViewControllers and it works fine as long as they use
>>> UITableViewStyle.Grouped.
>>>
>>> But when using UITableviewstyle.Plain the cells that are visible when
>>> the tableview appears, do not have the GradientColor. It is as if the
>>> BackgroundColor is Clear: they are rendered with the
>>> TableView.BackgroundColor as BackgroundColor.
>>>
>>> Scrolling cells that are out of view into view shows them with the
>>> gradient background color. Scrolling 'bad' cells out of view and back
>>> into view shows them with gradient color.
>>>
>>> Clicking one of the buttons so that a next controller is shown, and
>>> navigating back from that controller again shows all visible cells
>>> with clear background. Scrolling cells that are out of view into view
>>> renders them with the gradient color.
>>>
>>> The RootElement is (re)created in the ViewWillAppear method, so that any
>>> changes selected at a more detailed level can be reflected in the
>>> RootElement. And when populating it in the constructor rather than the
>>> ViewWillAppear, the debugger shows that the Root.TableView does not
>>> exist yet, so its BackgroundView can not be nulled, which is essential
>>> to be able to set the UITableView.BackgroundColor.
>>>
>>> I created the little demo project to isolate and hopefully solve this
>>> problem, but in that project the techniques also work with
>>> UITableViewStyle.Plain.
>>>
>>> Apparently there's still an aspect that differentiates the demo project
>>> from my apps, but to be honest, I'm out of inspiration.
>>>
>>> I hope that some more knowledgeable hacker can suggest something I could
>>> try or investigate to get this solved.
>>>
>>> I am eager to provide any additional information that might be useful to
>>> track this problem.
>>>
>>>
>>> Guido
>>>
>>> --
>>> People respond to people who respond.
>>>
>>> http://vanhoecke.org ... and go2 places!
>> _______________________________________________
>> MonoTouch mailing list
>> MonoTouch@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> --
> Nic Wise
> t.  +44 7788 592 806 | @fastchicken
> b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to