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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:31:41+00:00 2026-05-16T00:31:41+00:00

I want to create a blue rectangle image and see it in my view,

  • 0

I want to create a blue rectangle image and see it in my view, but this code doesn’t seem to work:

  CGRect imageRect = CGRectMake(50, 50, 64, 40);
  UIGraphicsBeginImageContext(imageRect.size);
  [[UIColor blueColor] set];
  UIRectFill(imageRect);
  UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  UIImageView *myImageView = [[UIImageView alloc] initWithImage:aImage];
  [self.view addSubview:myImageView]; 

Can someone fix it for me?

Thanks,

Sagiftw

  • 1 1 Answer
  • 1 View
  • 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-16T00:31:41+00:00Added an answer on May 16, 2026 at 12:31 am

    Your context is 64 points by 40 points. You filled a rectangle starting 50 points from the origin in a 40-point-tall context. That put it out of bounds, and anything you draw outside the bounds of the context won’t show up.

    Set your rectangle’s origin to 0,0, which is the origin of the context. Then, your 64×40-point rectangle will be completely within the bounds of your 64×40-point context.

    If you actually want to draw the rectangle 50 points below and to the right of the context’s origin, then you need to make the context’s size at least big enough to hold that margin plus the size of the rectangle. If you also want the same amount of margin on the other size, then the context’s size should be the rectangle’s size plus 100 points wide by 100 points tall (50 points on each side of the rectangle on each axis).

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

Sidebar

Related Questions

Am using the below code to create polygon. i just want to fill this
i want create image animation , i have 50 images with png format now
I have array with colors as its objects. I want to create an image
I want to create an html page with a watermark. I set the background-image
I want to create a UILabel and set its background to the gradient-blue like
i want to create an anonymous class in vb.net exactly like this: var data
I want to create a custom border with rounded corners. Code - import java.awt.BasicStroke;
I want to create a list of colors, red-yellow-green-blue, and blend into each other
I've an Array ['red', 'green', 'blue'] I want to create a new Hash from
I want to create multiple styles in the Window.Resources. Below is the code I

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.