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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:26:04+00:00 2026-05-28T00:26:04+00:00

This is the code I have: CGContextRef context = UIGraphicsGetCurrentContext(); CGColorRef redColor = [UIColor

  • 0

This is the code I have:

CGContextRef context = UIGraphicsGetCurrentContext();
    CGColorRef redColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor;

CGRect rectangle = CGRectMake(100, 100, 100, 100);
    CGRect inside = CGRectMake(120, 120, 60, 60);



CGContextSetFillColorWithColor(context, redColor);
CGContextSetBlendMode(context, kCGBlendModeNormal);
CGContextFillRect(context, rectangle);
CGContextSaveGState(context);

CGContextSetBlendMode(context, kCGBlendModeSourceOut);
CGContextFillRect(context, inside);
CGContextRestoreGState(context);

I’m trying to make the inside shape hollow, but instead it’s giving me a red square (as expecetd) with a black square in the middle, when the UIView in the background is white.

Any ideas on how to make the shape transparent here?

  • 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-05-28T00:26:05+00:00Added an answer on May 28, 2026 at 12:26 am

    There are a few ways you can fill your rectangle with a hollow inner rectangle. One way is to create a path that contains both rectangles, and fill it using the even-odd rule.

    CGContextRef gc = UIGraphicsGetCurrentContext();
    CGContextBeginPath(gc);
    CGContextAddRect(gc, CGRectMake(100, 100, 100, 100));
    CGContextAddRect(gc, CGRectMake(120, 120, 60, 60));
    CGContextSetFillColorWithColor(gc, [UIColor redColor].CGColor);
    CGContextEOFillPath(gc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: CGColorRef darkColor = [[UIColor colorWithRed:21.0/255.0 green:92.0/255.0 blue:136.0/255.0 alpha:1.0] CGColor]; CGContextRef
This is the code I have: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextClearRect(context, rect); CGContextSetFillColorWithColor(context, [BUTTON_COLOR
I have this code: - (CGImageRef)createImageWithContext:(CGContextRef)context { return CGBitmapContextCreateImage(context); } - (void)fooWithContext:(CGContextRef)context { CGImageRef
-(void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSelectFont(context, Arial, 24, kCGEncodingFontSpecific); CGContextSetTextPosition(context,80,80); CGContextShowText(context, hello, 6);
I have the following code: CGContextRef ctx = UIGraphicsGetCurrentContext(); UIGraphicsBeginImageContext(size); screenImageContext = UIGraphicsGetCurrentContext(); ctx
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
So I have this code that takes care of command acknowledgment from remote computers,
So I have this code in a google app engine template: <select name='voter'> {%

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.