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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:57:54+00:00 2026-06-02T15:57:54+00:00

I am using following code to color image on touch event.I have subclass uiview

  • 0

I am using following code to color image on touch event.I have subclass uiview and using following code to do that.It is working but color is different on different part of images.suppose i am coloring image with red color and there are green,yellow or other colors present in different part of images.then red color have different effects based on the color already present in image.Instead of that i want same red color(or whatever color selected) to be filled in the entire image.How can i achieve that?

@synthesize selImage,isReset;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        arrBezierPaths = [[NSMutableArray alloc] init];
        globalPath = [[UIBezierPath alloc] init];
        myPath = [[UIBezierPath alloc] init];

        self.userInteractionEnabled = TRUE;

        myPath.lineWidth = 30;
        brushPattern = [UIColor redColor];

        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:myPath, @"Path", brushPattern, @"Color", nil];
        [arrBezierPaths addObject:dict];
    }
    return self;
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    for (int i=0; i<[arrBezierPaths count]; i++)
    {
        NSDictionary *dict = [arrBezierPaths objectAtIndex:i];
        UIColor *tempBrushpatter = [[UIColor alloc] init];
        tempBrushpatter = [dict valueForKey:@"Color"];
        globalPath = [dict valueForKey:@"Path"];

        [globalPath strokeWithBlendMode:kCGBlendModeOverlay alpha:1.0];
        [tempBrushpatter setStroke];
    }
}

#pragma mark - Touch Methods

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *mytouch = [[touches allObjects] objectAtIndex:0];
    [globalPath moveToPoint:[mytouch locationInView:self]];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *mytouch = [[touches allObjects] objectAtIndex:0];
    CGPoint pointTouched = [mytouch locationInView:self];

    for (int i=0; i<[arrBezierPaths count]; i++)
    {
        UIBezierPath *tempErasePath = [[UIBezierPath alloc] init];
        NSDictionary *dictTemp = [arrBezierPaths objectAtIndex:0];
        UIBezierPath *temppath = [dictTemp valueForKey:@"Path"];
        if ([temppath containsPoint:pointTouched])
        {
            //[temppath removeAllPoints];
        }
    }

    [globalPath addLineToPoint:[mytouch locationInView:self]];

    [self setNeedsDisplay];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
}

-(void)changeColor:(UIColor *)color
{
    [arrRemovePaths removeAllObjects];
    UIBezierPath *temp = [[UIBezierPath alloc] init];

    temp.lineWidth = 30;
    UIColor *brushColor = color;
    NSLog(@"initWithFrame method called");
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:temp, @"Path", brushColor, @"Color", nil];
    [temp release];
    [arrBezierPaths addObject:dict];
    brushPattern = [color retain];
    [self setNeedsDisplay];
}

- (void)dealloc
{
    // [brushPattern release];
    [super dealloc];
}
  • 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-02T15:57:56+00:00Added an answer on June 2, 2026 at 3:57 pm

    try replacing the line [globalPath strokeWithBlendMode:kCGBlendModeOverlay alpha:1.0]; with

    [globalPath strokeWithBlendMode:kCGBlendModeCopy alpha:1.0];
                ;
    

    If you want to how the different blend mode works look here(Figure 2-1).

    Blend Modes

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

Sidebar

Related Questions

i have to change image color dynamically using php i used the following code
I am using the following code to submit different values var evalue= 'color:#d32;font-size:12px;'; jQuery.ajax({
I am using the following code to blur an image in android, but it
I want to display images using different color maps in different figures. Following code
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I'm creating a color object using the following code. curView.backgroundColor = [[UIColor alloc] initWithHue:229
For pop up im using the following code style : a.selected { background-color:#1F75CC; color:white;
I am using the following code, UIManager.put(JFrame.activeTitleBackground, Color.red); for change the toolbar color in
I am using the following code(no my own code) to load image to a
When I set repeating background image to a UITableView by using the following code

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.