• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: drawing in uiview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing in uiview


  • Subject: Re: drawing in uiview
  • From: Randall Meadows <email@hidden>
  • Date: Mon, 12 Oct 2009 09:00:41 -0600

On Oct 10, 2009, at 11:41 AM, Jos Timanta Tarigan wrote:

i got a very basic question on iphone development. so i add an uiview via IB and try to update it by making my own interface called updateInterface(). in the update interface i put this code:

Why would you do that instead of using the UIView method intended to do drawing, -drawRect:?


Subclass UIView, and put the following code into it.

CGRect frame = [polyView frame];
NSArray*polypath = [[selfclass]pointsForPolygonInRect:frame numberOfSides:[myPolynumberOfSides]];
CGContextRefmyContext = UIGraphicsGetCurrentContext();
int i = 0;
CGContextSetRGBStrokeColor(myContext, 0, 0, 1, 1);
for (NSValue* value in polypath) {
CGPoint point = [value CGPointValue];
if (i == 0) {
CGContextMoveToPoint(myContext, point.x, point.y);
i++;
}
else {
CGContextAddLineToPoint(myContext, point.x, point.y);
}
}
CGContextClosePath(myContext);
im trying to draw a polygon here built by lines from one point to antoher. the "pointsForPolygonInRect" is working properly but my UIview(polyView) isnt showing anything. i dont really understand what happened up there, i just googled it around working for a proper method. im very new to cocoa-dev so please do a more human language ;)

You might also want to actually *draw* the path; see "Painting Paths" <file:///Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_0.iPhoneLibrary.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/doc/uid/TP30000950-CH1g-TPXREF107 > (you set the stroke color, but then don't actually stroke the path).


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >drawing in uiview (From: Jos Timanta Tarigan <email@hidden>)

  • Prev by Date: Hiding tab view items
  • Next by Date: Re: Hiding tab view items
  • Previous by thread: drawing in uiview
  • Next by thread: RE: IBPlugin Inspector: get contents of the Library Media tab
  • Index(es):
    • Date
    • Thread