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

  • Home
  • SEARCH
  • 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 7876185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:07:44+00:00 2026-06-03T03:07:44+00:00

I am subclassing a UIView and am calling it via a detail view controller.

  • 0

I am subclassing a UIView and am calling it via a detail view controller. When I load it, it shows up with the right dimensions and positioning, however it is just a black square… When I just put a UIView into interface builder with the class, it works. I don’t think draw rect is called. Heres my code:

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self setNeedsDisplay];
    }
    return self;
}


- (void)drawRect:(CGRect)rect
{
    // Drawing code

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 255.0, 255.0, 0, 1);
    CGContextStrokeRect(context, CGRectMake(0, 0, 50, 50));
}

and I call it like so:

 GameBox *boxy = [[GameBox alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
    [self.view addSubview: boxy];
  • 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-03T03:07:45+00:00Added an answer on June 3, 2026 at 3:07 am

    You are setting your fill color but you are stroking a rect. You need to set the stroke color: CGContextSetRGBStrokeColor

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

Sidebar

Related Questions

I am doing subclassing of UIView, how do I do Left and Right text
I am subclassing UIView, retrieving a remote image then drawing it to the view
I'm subclassing UIView to make a custom view by overriding drawRect:. I need to
Possible Duplicate: Subclassing UIView to draw in Quartz Hello i am searching good example
I'm subclassing UIView using the standard EAGLView framework. When I detect orientation changes, I
I have a Custom Scroll View, subclassing UIScrollView . I have added a scroll
I'm working on creating a UIView subclass (which I'm calling MarqueeLabel ) that animates
I am currently subclassing UIView to create custom objects, they work perfectly fine In
I'm writing a small painting app for iOS. I'm subclassing a UIView ad performing
How can I make part of a UIView transparent without subclassing? Or is subclassing

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.