[Tutorial] Drawing to the screen.

Discussion in 'iOS Development' started by SkylarEC, Jan 16, 2009.

  1. ipodmail09 Member

    Member Since:
    Mar 13, 2009
    Message Count:
    270
    Device:
    2G iPod touch
    having trouble changing the colour of paint ?
  2. Axis Super Moderator

    Member Since:
    Dec 2, 2007
    Message Count:
    6,280
    Device:
    iPhone 4S (White)
    [OBJC]
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), /* red */ 1.0, /* green */ 0.0, /* blue */ 0.0, /* alpha */ 1.0);
    [/OBJC]

    Set floats (0.0 - 1.0) for each RGB color, and the last one for alpha (opacity).

    Documentation is a gold mine:

  3. ipodmail09 Member

    Member Since:
    Mar 13, 2009
    Message Count:
    270
    Device:
    2G iPod touch
    Thank you so much and its true apple doc are a gold mine
  4. johnryan New Member

    Member Since:
    Mar 24, 2009
    Message Count:
    1
    I noticed earlier that someone was having problems with drawing in a horizontal view. I am having the same problem. I was wondering if anyone had a solution to this problem. It is as if when the interface rotates the "view" that the drawing happens on doesn't rotate. This results in me being unable to draw on the right 25% of the screen. ANY help would be GREATLY appreciated. Thanks!
  5. nonsgeormug New Member

    Member Since:
    Apr 30, 2010
    Message Count:
    1
    Tutorial Drawing to the screen

    One course of action is to place all your annotations in a layer where you overload render. Before calling surper.render, you adjust the annotations size and on-screen positions according to the draw context and viewport size.

    Does this make sense?
  6. anant New Member

    Member Since:
    May 4, 2010
    Message Count:
    1
    hey i have used tis application and also edited it to change the brush size and color!!..now i want to add a new feature i want to scribble on images in iphone and also save those images. I want to change the photos in the background in run time.
    can you please help me
  7. lauNchD Well-Known Member

    Member Since:
    Jan 27, 2008
    Message Count:
    1,395
    Device:
    iPhone 5 (Black)
    Please don't just steal/"use" this sample code without attribution, even if you add features. Try to code it yourself as a kind of 'exercise.'

    </OT> Use UIImagePickerController (or the new asset stuff in the 4.0 beta, but you probably don't have it) to get an image. The easiest (but not the best) way is just to place a UIImageView behind the drawing view. When the user clicks the Save button, composite the picture again with the chosen image in the background and use the UIImageSave*something* function to save it.
  8. Wayman New Member

    Member Since:
    May 5, 2010
    Message Count:
    5
    I need help!!!!!!!!!!!!!!!

    Please please please please please help me!!!!!!!!!!
    I wanted to add a ON and OFF button to my drawing application!!! When I open the app I don't want the drawing funtion to be enabled until I push a certain button!! Please help me!!!!!! If you have a source code I could download I would be very grateful!!!!!!!!!!
    Please someone!!!!!! Please help me. I'm new to Xcode and I'm really hoping one of you great people can help me.

    Thank you so much for considering!!!
  9. lauNchD Well-Known Member

    Member Since:
    Jan 27, 2008
    Message Count:
    1,395
    Device:
    iPhone 5 (Black)
    To quote myself:
    You really shouldn't start iPhone development by copying a drawing app that you don't understand. If you don't even know how to interact with a UISwitch and change the 'logic' appropriately, you should follow some "beginner" tutorials first.

    If you have actual, concrete problems implementing this, we could help you some more.
  10. wat. New Member

    Member Since:
    Sep 14, 2009
    Message Count:
    202
    Device:
    iPad
    How can you change the affected view of the painting overlay? As-is, it's stuck in portrait mode, and comes short of the top of the screen. How can this image view overlay get sized differently?