Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:11:47+00:00 2026-05-16T11:11:47+00:00

What is the importance of drawRect, layoutSubViews and setNeedsDisplay methods. In which contexts we

  • 0

What is the importance of drawRect, layoutSubViews and setNeedsDisplay methods. In which contexts we should use them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:11:47+00:00Added an answer on May 16, 2026 at 11:11 am

    As in the documentation says:

    drawRect: Draws the receiver’s image within the passed-in rectangle. 
    

    Parameters

    rect : A rectangle defining the area to restrict drawing to.

    You use this method to draw your UIView inside a specific rect of a view.

    • (void)setNeedsDisplay

    By default, geometry changes to a view
    automatically redisplays the view
    without needing to invoke the
    drawRect: method. Therefore, you need
    to request that a view redraw only
    when the data or state used for
    drawing a view changes. In this case,
    send the view the setNeedsDisplay
    message. Any UIView objects marked as
    needing display are automatically
    redisplayed when the application
    returns to the run loop.

    I think that this method let you control if you want the system automatically redraw your UIView for you or not. If you want to control the process by your own state like: if the user click this button, redraw; otherwise, don’t.

    Lays out subviews.

    • (void)layoutSubviews

    Overridden by subclasses to layout
    subviews when layoutIfNeeded is
    invoked. The default implementation of
    this method does nothing.

    I have not much experience with this method. What I can tell you is that you need to override it to layout your subviews

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody explain the importance of NSNotificationCenter? Where to use them? What is the
What is the use and importance of IMetadataExchange in WCF? I have the following
What is the use and importance of studying theory of computation ? I had
This is not really of importance but I am still curious whetever I should
I am trying to find an equation which calculates the importance of a twitter
What are the top issues and in which order of importance to look into
I'm trying to illustrate the use and importance of volatile with an example that
Question My question is how can you teach the methods and importance of tidying-up
Consider an SVN repository which has a file with great production importance: . ├──
I didn't understood importance of three tests in case of STUN ? STUN server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.