Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6005033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:20:47+00:00 2026-05-23T01:20:47+00:00

I have a specification to build a very simple diagramming capability into a MonoTouch

  • 0

I have a specification to build a very simple diagramming capability into a MonoTouch app. Everything I’ve had to do up to now has been table based so this is new territory.

Numerous examples of diagramming can be found in the app store, for example the MindMeister and SimpleMind mindmapping apps.

I need users to be able to click on a view to “put down” a new shape, label it, and optionally connect it to an existing shape.

What would be a good approach to achieve this kind of interactive functionality? My first would be to put down a UIImageView created from a custom image, and then ensuring that it can respond to touch events to move it around. However, when you want to add a text overlay, matters become more complicated as you’d have to manage two views (both the image and the text).

What approach could I follow?

PS: Smite at will if this is inappropriate for SO!

Update: Basic diagram elements can be achieved by using a simple label override:

UILabel lbl = new UILabel(new RectangleF(...));
lbl.Text = "Whatever";
lbl.Layer.BorderWidth = 3f;
lbl.Layer.BorderColor ( new CGColor (1f, 0f, 0f) );
this.Add (lbl);

Some interactivity can be achieved by extending the gui element class and overriding the TouchesBegan, TouchesMoved and TouchesEnd events.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:20:47+00:00Added an answer on May 23, 2026 at 1:20 am

    What you want to do is not that difficult. I do not have an example ready, but I will give you some steps that might help you getting started.

    1. Create a custom view, inheriting
      UIView. This will hold your shape
      and text.
    2. Add two subviews in it. The
      UIImageView that will hold your
      shape and a UILabel for the text.
    3. Override your custom view’s Draw
      method. Inside it you can copy the contents of the view to an image context.
    4. Assign the image from that context,
      to another layer.
    5. Move that layer around, responding
      to user touches on your custom
      view’s superview.

    Simple example:

    public CALayer ContentsLayer { get; set; }
    public override void Draw (RectangleF rect)
    {
        base.Draw(rect);
    
        // Create an image context
        UIGraphics.BeginImageContext(this.Bounds.Size);
    
        // Render the contents of the view to the context
        this.Layer.RenderInContext(UIGraphics.GetCurrentContext());
    
        // Assign the contents to the layer
        this.ContentsLayer = new CALayer();
        this.ContentsLayer.Contents = UIGraphics.GetImageFromCurrentImageContext().CGImage;
    
        // End the context
        UIGraphics.EndImageContext();
    }
    

    This example is quite simple and should not be used as it is. For example, you should provide logic for when to receive the contents of your custom view. If you leave it like this, every time the Draw method gets called it will create a new context. You only need to do this once.

    After copying the contents to a layer, you can move around that layer anywhere you want through your superview, by adding it to your superview’s layer and modifying its frame. You do not have to create another custom view for your superview, you can just create a custom UIGestureRecognizer, override its own Touches* methods and add it to the superview.

    This way you have one object to move around (the layer) that holds both your shape and your text.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to the Component Object Model specification - I have a simple
For a project I have a specification with formulas, I have to implement. In
I have read about partial methods in the latest C# language specification , so
Have you guys had any experiences (positive or negative) by placing your source code/solution
I have used JMS in the past to build application and it works great.
Real World Problem: I have my app hosted on Heroku , who (to my
If I have a specification defined as an Expression as below: public Expression<Func<Foo, bool>>
Ok guys just a small game: I have some specifications for a project. At
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.