• 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: Basic, but still confuses me (initWithFrame and drawRect)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic, but still confuses me (initWithFrame and drawRect)


  • Subject: Re: Basic, but still confuses me (initWithFrame and drawRect)
  • From: David Duncan <email@hidden>
  • Date: Fri, 19 Jun 2009 09:56:02 -0700

On Jun 19, 2009, at 9:26 AM, Chunk 1978 wrote:

i don't understand the difference between the 2.  i think i'm suppose
to simply set the frame size in initWithFrame method, and set
attributes (like background color, and clipping masks, etc.) in the
drawRect method.


-initWithFrame: is one of the designated initailizers for a UIView (the other is -initWithCoder: for loading from a NIB). When - initWithFrame: completes, the view needs to be initialized to the point that it can do something useful.

-drawRect: is just for drawing. You should be doing as little as possible inside of -drawRect: and it should all be 100% related to drawing the content of your view. You may read from various properties, but you almost never set them.
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

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


  • Follow-Ups:
    • Re: Basic, but still confuses me (initWithFrame and drawRect)
      • From: Chunk 1978 <email@hidden>
References: 
 >Basic, but still confuses me (initWithFrame and drawRect) (From: Chunk 1978 <email@hidden>)

  • Prev by Date: Inspecting synthesized variables in gdb
  • Next by Date: Rosetta Booster Conclusion - It Works
  • Previous by thread: Basic, but still confuses me (initWithFrame and drawRect)
  • Next by thread: Re: Basic, but still confuses me (initWithFrame and drawRect)
  • Index(es):
    • Date
    • Thread