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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:43:30+00:00 2026-06-12T09:43:30+00:00

My code was working when I was using UIViews and changing their background color.

  • 0

My code was working when I was using UIViews and changing their background color. Now I try it with ellipses and they don’t show up? Here is the code:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
        overlayView = [[[UIView alloc] initWithFrame:self.view.bounds] autorelease];
        overlayView.backgroundColor = [UIColor colorWithWhite:255.0f alpha:1.0f];
    [self.view addSubview:overlayView];
    reda = 0;
    bluea = 0;
    greena = 255;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    touchPoint = [touch locationInView:self.view];
    previousPoint = touchPoint;

}

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    touchPoint = [touch locationInView:self.view];
    if (abs((previousPoint.x-touchPoint.x)) > 20) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Too Fast!" delegate:self cancelButtonTitle:@"Okay." otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    }
    CGContextRef contextRef = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(contextRef, reda/255.f, greena/255.f, bluea/255.f, 1.0f);
    CGContextFillEllipseInRect(contextRef, CGRectMake(touchPoint.x, touchPoint.y, 20, 20));
    [overlayView addSubview:contextRef];

    if ((greena != 0) && (bluea == 0)) {
        greena += -5;
        reda += +5;
    }
    if ((reda != 0) && (greena == 0)) {
        bluea += +5;
        reda += -5;
    }
    if ((bluea != 0) && (reda == 0)) {
        bluea += -5;
        greena += +5;
    }
}
  • 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-12T09:43:31+00:00Added an answer on June 12, 2026 at 9:43 am

    You are calling UIGraphicsGetCurrentContext in touchesMoved:withEvent:. The system doesn’t create a graphics context for you in touchesMoved:withEvent:. The system only creates a graphics context for you in -[UIView drawRect:].

    You need to read about the view drawing cycle and the runtime interaction model for views in Apple’s documentation.

    You can either move your drawing code to drawRect:, or you can create your own graphics context (e.g. using UIGraphicsBeginImageContextWithOptions or CGBitmapContextCreate), draw to it, and then create an image from the context and assign the image to view.layer.contents.

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

Sidebar

Related Questions

I am using the following code for my form validation. The code is working
I'm porting some (working) code from Linux to Windows 8. I'm using DDK. typedef
i am using python 2.5.2 . The following code not working. def findValue(self, text,
I have a jQuery code, but need it working by using Mootools: if (
I'm working some code that inserts csv rows into an SQLite database using Python.
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I've recently been working with code that looks like this: using namespace std; class
I'm working on a website using extensively javascript. The code I'm working on also
I am working on some code using the EMF framework in Java, but it
I am using the below code to block the taskbar which is working perfectly.

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.