UIView Custom Drawing

Discussion in 'iPhone/iPad Programming' started by dgdosen, Jul 22, 2008.

  1. macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #1
    Anyone have sample code or know how to draw a rounded rectangle (similar to the rounded rect UI Button, or the rounded view on a grouped table)

    I want to draw custom data on a View, and want to keep the look consistent with the rest of the app. I want to frame it all in a rounded rectangle, as if it's in a button. Anyone know of sample code to do that?

    Do you need to create small regions in each corner and draw quarter circles? Or is there a simple API to do that?

    Or would you say I should just draw directly on an already rounded button?
     
  2. thread starter macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #2
    If I try to draw on a rounded rectangle, I can't take advantage of the DrawRect function in the View...

    argh... There should be a sample on this...
     
  3. thread starter macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #3
    Doh! Nevermind - I see this in QuartzDemo...
     
  4. thread starter macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #4
    As a follow up: Does anyone know how to draw custom text on a UIView?

    I can draw graphics well enough based on samples - but when I follow the documentation to write text to the context, it doesn't show up. The color and alpha should show up on the background, but I'm afraid it's not showing.

    Code:
    	
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSelectFont(context, "Verdana", 10, kCGEncodingMacRoman);
    CGContextSetCharacterSpacing (context, 10); 
    CGContextSetTextDrawingMode (context, kCGTextStroke); 
    	
    CGContextSetRGBFillColor (context, 0, 0, 0, 0);
    CGContextSetRGBStrokeColor (context, 0, 0, 0, 0);
    	
    CGContextShowTextAtPoint (context, 40, 40, "TestTest", 9);
    
    Any help? Also - is there a better way of drawing text right on the context?

    Any advice would be greatly appreciated...
     
  5. macrumors newbie

    Joined:
    Oct 6, 2008
    #5
    change alpha value to 1

    ...........
     

Share This Page