Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dgdosen

macrumors 68030
Original poster
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?
 
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...
 
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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.