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

Similar Threads
thread Thread Starter Forum Replies Last Post
How do I reference a subview in a custom UIView class? moonman239 iPhone/iPad Programming 1 Nov 7, 2013 01:38 PM
Trying to subclass UIView Hans Kamp iPhone/iPad Programming 3 Mar 25, 2013 12:15 AM
Springtomize 2 Custom Time Mode - Custom String GUILTIE Jailbreaks and iOS Hacks 10 Mar 7, 2013 03:18 PM
Archiving Custom UIView Ides iPhone/iPad Programming 14 Aug 8, 2012 05:44 PM
make uiview transparent without having the uiview's buttons transparent johnmerlino iPhone/iPad Programming 7 Jun 1, 2012 02:20 AM

Forum Jump

All times are GMT -5. The time now is 06:42 AM.

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

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