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 8146475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:00:55+00:00 2026-06-06T14:00:55+00:00

Hey guys just a quick question about the performance of drawRect: as I’ve noticed

  • 0

Hey guys just a quick question about the performance of drawRect: as I’ve noticed a lot of topics with people complaining about performance issues.

In my App, I need to draw ~150 squares overtop some underlaying views. Obviously this many calls isn’t going to have a noticeable user difference, but I’m just wondering about the pros and cons going forward. Currently I’m debating two ways:

1) add a transparent UIView subclass on top with a custom drawRect: to facilitate the drawing

2) just add normal square subviews

As I said, using CADisplayLink there won’t be any difference to the user, I’m just curious what would be more efficient? (2) is kind of a ridiculous way of doing it, adding instances with useless functionality just for appearance, but all these posts have just scared me into using drawRect. Is drawRect really that inefficient?

Thanks

  • 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-06-06T14:00:57+00:00Added an answer on June 6, 2026 at 2:00 pm

    Perhaps unintuitively, drawRect: isn’t called for every frame. In fact, if you do nothing special in your view and your view itself doesn’t change, it gets called once.

    You can force it to be called by calling [myView setNeedsDisplay], but there usually is no reason to.

    If you have a view with overlapping subviews, still for each of those views, including the superview, drawRect: is only called once. Then, the GPU does the compositing (blending).

    A custom drawRect: is almost always slower (and harder) than just using UIKit the way it was intended, if UIKit already offers what you want to do.

    Also don’t fall into one of the biggest traps in software development, premature optimization. Code the most naive version, benchmark it, and if it’s fast enough, it’s good enough, and you can focus your energy elsewhere. Only start optimizing once you know that something is actually slow, and where and why it is.

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

Sidebar

Related Questions

Hey guys just a quick question, I am posting mp3s in dialog boxes each
Hey guys quick question, I am currently echoing a lot of javascript that is
Hey guys, quick question, just trying to filter a user's first and last name
Hey guys, quick question, I have an id that is applied multiple times on
Hey guys I just noticed that my join statement here SELECT * FROM reports
Hey guys, I haven't used the rpg pattern before, and had a quick question.
Hey guys, I'm just starting out with MySQL and PHP and have a question.
Hey guys this question is a bit nebulous so I apologize...I'm just looking for
Hey guys, just learning about composition of classes and ran into this error. Gradebook.h
hey guys, probably weird question, i'm just curious. Is there any way to kind

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.