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

Basic, but still confuses me (initWithFrame and drawRect)


  • Subject: Basic, but still confuses me (initWithFrame and drawRect)
  • From: Chunk 1978 <email@hidden>
  • Date: Fri, 19 Jun 2009 12:26:25 -0400

i want to create a UIView programatically... so i have the 2 main
methods of UIView:  InitWithFrame, and drawRect.

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.



- (id)initWithFrame:(CGRect)frame
	{
	if (self = [super initWithFrame:frame])
		{
		CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
		frame = fullScreenRect;
		}
		return self;
	}

- (void)drawRect:(CGRect)rect
	{
	self.backgroundColor = [UIColor blueColor];
	}



i know this is wrong (since my main app controller isn't adding this
view it to it's subview), but it's what makes sense to me...  can
someone make sense of all this for me?
_______________________________________________

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: Grant Erickson <email@hidden>
    • Re: Basic, but still confuses me (initWithFrame and drawRect)
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Just implementing -isEqual:, never invoked, causes crash
  • Next by Date: Re: Just implementing -isEqual:, never invoked, causes crash
  • Previous by thread: Re: Just implementing -isEqual:, never invoked, causes crash
  • Next by thread: Re: Basic, but still confuses me (initWithFrame and drawRect)
  • Index(es):
    • Date
    • Thread