You could also try with UIBezierPath, you need to override UIView Draw method.

Here is the example, so first you need to subclass UIView, then open up Xcode if you want, add UIView on the canvas, resize it as you like, go to the inspector, Custom Class, and choose your custom class.

using System;
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.Foundation;

namespace Drawing
{
    [Register ("View")]
    public class View : UIView
    {
        public View (IntPtr handle) : base (handle) 
        {

        }

        public View () : base ()
        {
        }

        public override void Draw (System.Drawing.RectangleF rect)
        {
            base.Draw (rect);

            //Drawing with help of UIBezierPath
            //When using UIBezierPath you dont need to get graphics context
            UIBezierPath path = new UIBezierPath();
            
            path.MoveTo(new PointF(75,10));
            path.AddLineTo(new PointF(160,150));
            path.AddLineTo(new PointF(10,150));
            path.ClosePath();
            
            //With code above we actually didnt draw anything, we just described a path
            //You need to set color for lines 
            
            UIColor.Yellow.SetFill();
            UIColor.Red.SetStroke();
            
            path.Fill();
            path.Stroke();

        }
    }
}




On 2013.03.26 13:38, Nic Wise wrote:
http://stackoverflow.com/questions/4685589/very-simple-test-view-in-monotouch-draws-a-line-using-core-graphics-but-view-con

With code (tho, as the first answer points out, it's Draw(RectangleF)
not Draw(RectangleF, UIViewPrintFormatter)





On 22 March 2013 15:40, jenia <[email protected]> wrote:
Using Monotouch, how would I draw a simple line  in a uiview that is
currently being display?

Simple example is of course fine.



--
View this message in context: http://monotouch.2284126.n4.nabble.com/Line-at-Uiview-tp4658178.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch



-- 
Miljenko Cvjetko dipl.ing. ET
	Direktor/CEO
	Projektant rješenja/Solution Architect	
	Razvojni programer/Senior developer
	Voditelj projekta/Project Manager

IX južna obala 13
Kajzerica Zagreb
T: 385 1 7775555
M: 385 91 557 447 3
F: 385 1 7779556
e: [email protected]
w: http://holisticware.net
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to