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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:53:54+00:00 2026-06-16T10:53:54+00:00

I have a custom class which I derived from the UIView class. What I

  • 0

I have a custom class which I derived from the UIView class. What I want to accomplish is just drawing vertical black lines with a predefined distance between. When I override the drawRect method and write my code to draw vertical lines, the view just shows a complete black background. Then I noticed that even an empty overridden drawRect which only calls the superclass’ drawRect results in a black background. When I comment out the drawRect, then the view shows through and becomes transparent as I expected.

This is the only code I am using in the drawRect which just calls the superclass method:

- (void)drawRect:(CGRect)rect
{
   [super drawRect:rect];

}

What can be reason of this behavior?

  • 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-16T10:53:55+00:00Added an answer on June 16, 2026 at 10:53 am

    It’s quite likely that there is some under-the-hood shenanigans going on with UIView, and that the base class doesn’t actually implement drawRect, or some sneaky optimisation is happening.

    The documentation does say not to call super if you are directly overriding UIView, and it also says you don’t need to implement drawRect if all you do is set a background colour or you populate the content in other ways:

    The default implementation of this method does nothing. Subclasses that use native drawing technologies (such as Core Graphics and UIKit) to draw their view’s content should override this method and implement their drawing code there. You do not need to override this method if your view sets its content in other ways. For example, you do not need to override this method if your view just displays a background color or if your view sets its content directly using the underlying layer object. Similarly, you should not override this method if your view uses OpenGL ES to do its drawing.

    And:

    If you subclass UIView directly, your implementation of this method does not need to call super. However, if you are subclassing a different view class, you should call super at some point in your implementation.

    It’s therefore quite likely that by calling super you are losing something. You don’t show any of your actual drawing code so its difficult to see where you might be going wrong with that, but as a starting point, don’t call super if you’ve directly overridden UIView.

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

Sidebar

Related Questions

I want to build a jar containing a class which I have derived from
I have a class derived from slider which uses a custom control template and
I have created a custom class derived from Canvas, which contain elements which will
I have a class derived from TreeviewItem(Custom TreeViewItem) which is used by a class
I have a custom class which I want to load inside the firstViewController and
I have a custom FrameLayout class which does some custom drawing on the OnSizeChanged
I have a custom class loader which extends from a URLClassLoader. I added a
I have a IEnumerable. I have a custom Interval class which just has two
I have an NSOperationQueue to which i have added my custom class's objects(inherits from
I have an application where I have one custom view which is derived from

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.