Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 22, 2008, 02:09 PM   #1
louden
macrumors 65816
 
louden's Avatar
 
Join Date: Dec 2003
Location: Seattle
UIView Custom Drawing

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?
__________________

Dell Pentium 2 with 500 MB HD Windows 95
Compaq iPaq w/ 64MB of Ram
louden is offline   0 Reply With Quote
Old Jul 22, 2008, 02:42 PM   #2
louden
Thread Starter
macrumors 65816
 
louden's Avatar
 
Join Date: Dec 2003
Location: Seattle
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...
__________________

Dell Pentium 2 with 500 MB HD Windows 95
Compaq iPaq w/ 64MB of Ram
louden is offline   0 Reply With Quote
Old Jul 22, 2008, 02:49 PM   #3
louden
Thread Starter
macrumors 65816
 
louden's Avatar
 
Join Date: Dec 2003
Location: Seattle
Doh! Nevermind - I see this in QuartzDemo...
__________________

Dell Pentium 2 with 500 MB HD Windows 95
Compaq iPaq w/ 64MB of Ram
louden is offline   0 Reply With Quote
Old Jul 23, 2008, 11:14 AM   #4
louden
Thread Starter
macrumors 65816
 
louden's Avatar
 
Join Date: Dec 2003
Location: Seattle
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...
__________________

Dell Pentium 2 with 500 MB HD Windows 95
Compaq iPaq w/ 64MB of Ram
louden is offline   0 Reply With Quote
Old Oct 23, 2008, 05:58 AM   #5
dipaliP
macrumors newbie
 
Join Date: Oct 2008
change alpha value to 1

...........
dipaliP is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
I need to use custom drawing to draw an NSImage. ausername Mac Programming 4 May 8, 2009 12:48 AM
UITableView / Cell Custom Draw elronaldo iPhone/iPad Programming 8 Oct 1, 2008 06:45 AM


All times are GMT -5. The time now is 11:01 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC