Line at Uiview

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Line at Uiview

jenia
Using Monotouch, how would I draw a simple line  in a uiview that is currently being display?

Simple example is of course fine.
Reply | Threaded
Open this post in threaded view
|

Re: Line at Uiview

Nic Wise
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 <[hidden email]> 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
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch



--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Line at Uiview

moljac
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 [hidden email] 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
[hidden email]
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: [hidden email]
w: http://holisticware.net

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Line at Uiview

Gerry High
In reply to this post by jenia
Albeit kinda hackish you can also do this inside of Interface Builder using a 1px wide (or tall) control (e.g. label) and then setting it's color to whatever you want the line to be.

Gerry

On Mar 22, 2013, at 10:40 AM, jenia <[hidden email]> 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
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch