No problem.

On Wed, Jun 20, 2012 at 10:51 AM, Guido Van Hoecke <[email protected]> wrote:
> Thanks Nic!
>
> On 20 June 2012 11:39, Nic Wise <[email protected]> wrote:
>> I use this for a color + 2 labels header, and for image + label version:
>>
>> https://gist.github.com/2959075
>>
>> The background image I use for the second one is just a thin sliver
>> (10px wide?) of gradient.
>>
>> You can see the results of both here:
>>
>> http://www.fastchicken.co.nz/tripwallet/
>> (second shot down)
>>
>> and here:
>> http://www.earnestapp.com/ (second screenshot in the cycle, the list of 
>> items)
>>
>>
>>
>> On Tue, Jun 19, 2012 at 6:55 PM, Guido Van Hoecke <[email protected]> wrote:
>>> Hi,
>>>
>>> I have this Monotouch.Dialog app with UITableViewStyle.Plain that uses a
>>> custom header:
>>>
>>>        root.Add(
>>>                new Section{
>>>                        HeaderView = new CustomHeader
>>>                        });
>>>
>>> I need the custom header while I need to position the text at computed
>>> coordinates:
>>>
>>> namespace MySpace
>>> {
>>>        private const float _height = 23f;
>>>        public class CustomHeader : UIView
>>>        {
>>>                private string _title;
>>>                public CustomHeader(string title) : base(new RectangleF(0f, 
>>> 0f,
>>>                        UIScreen.MainScreen.ApplicationFrame.Width, _height))
>>>                {
>>>                        _title = title;
>>>                }
>>>
>>>                public override void Draw(RectangleF rectangle)
>>>                {
>>>                        UIColor.LightGray.SetFill();
>>>                        var context = UIGraphics.GetCurrentContext();
>>>                        context.FillRect(rectangle);
>>>                        UIColor.Black.SetColor();
>>>                        // define variables x, y, width, height,
>>>                        // and then draw the text
>>>                        DrawString(_title, new RectangleF(x, y, width, 
>>> height),
>>>                                MyConfig.BoldFont, 
>>> UILineBreakMode.TailTruncation);
>>>                }
>>>        }
>>> }
>>>
>>> But I want to use a background image.
>>>
>>> First idea was to base my CustomHeader on UIImageView rather than
>>> UIView:
>>>
>>> namespace MySpace
>>> {
>>>        private const float _height = 23f;
>>>        public class CustomHeader : UIImageView
>>>        {
>>>                private string _title;
>>>                public CustomHeader(string title) : base(new RectangleF(0f, 
>>> 0f,
>>>                        UIScreen.MainScreen.ApplicationFrame.Width, _height))
>>>                {
>>>                        _title = title;
>>>                        BackGroundColor = UIColor.Clear;
>>>                        Image = UIImage.FromFile("Image.png");
>>>                }
>>>
>>>                public override void Draw(RectangleF rectangle)
>>>                {
>>>                        ...
>>>                }
>>>        }
>>> }
>>>
>>> This shows the background, but without text as the Draw method is no
>>> longer called.
>>>
>>> Then I tried to stick with the UIView, and add an UIImageView:
>>>
>>> namespace MySpace
>>> {
>>>        private const float _height = 23f;
>>>        public class CustomHeader : UIView
>>>        {
>>>                private string _title;
>>>                public CustomHeader(string title) : base(new RectangleF(0f, 
>>> 0f,
>>>                        UIScreen.MainScreen.ApplicationFrame.Width, _height))
>>>                {
>>>                        _title = title;
>>>                        BackGroundColor = UIColor.Clear;
>>>                var bg = new UIImageView {
>>>                                Frame = new RectangleF(0f, 0f,
>>>                                        
>>> UIScreen.MainScreen.ApplicationFrame.Width, Height),
>>>                    BackgroundColor = UIColor.Clear,
>>>                    Image =
>>> UIImage.FromFile("Images/TableViewPlainHeaderBackground.png")
>>>                };
>>>                        AddSubView(bg);
>>>                        SendSubviewToBack(bg);
>>>                }
>>>
>>>                public override void Draw(RectangleF rectangle)
>>>                {
>>>                        ...
>>>                }
>>>        }
>>> }
>>>
>>> This approach also shows the image, but no text.
>>>
>>> I have the distinct feeling that this should be fairly simple, but
>>> apparently I need some help here.
>>>
>>> Thanks in advance,
>>>
>>>
>>> Guido
>>>
>>> --
>>> You need only reflect that one of the best ways to get yourself a
>>> reputation as a dangerous citizen these days is to go about repeating
>>> the very phrases which our founding fathers used in the struggle for
>>> independence.
>>>                -- Charles A. Beard
>>> _______________________________________________
>>> MonoTouch mailing list
>>> [email protected]
>>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
>>
>>
>> --
>> Nic Wise
>> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
>> b. http://www.fastchicken.co.nz/
>>
>> Earnest: Self-employed? Track your business expenses and income.
>> http://earnestapp.com
>> Nearest Bus: find when the next bus is coming to your stop. 
>> http://goo.gl/Vcz1p
>> mobileAgent (for FreeAgent): get your accounts in your pocket.
>> http://goo.gl/IuBU
>> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
>> London Bike App: Find the nearest Boris Bike, and get riding! 
>> http://goo.gl/Icp2



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Earnest: Self-employed? Track your business expenses and income.
http://earnestapp.com
Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to