xcode6 - change alpha of a UIImage then use as colorWithPatternImage -


i have drawing app use preexisting .png images draw textured colors uiimageview.

//basic drawing stuff

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {    ctr = 0;     pts[0] = [touch locationinview:self.tempimage];      lastpoint = [touch locationinview:tempimage];     }   - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event {   uitouch *touch = [touches anyobject];             cgpoint p = [touch locationinview:self.tempimage];     currentpoint = [touch locationinview:tempimage];     ctr++;     pts[ctr] = p;      if (ctr == 4)      {         pts[3] = cgpointmake((pts[2].x + pts[4].x)/2.0, (pts[2].y + pts[4].y)/2.0); // move endpoint middle of line joining second control point of first bezier segment , first control point of second bezier segment          [path movetopoint:pts[0]];         [path addcurvetopoint:pts[3] controlpoint1:pts[1] controlpoint2:pts[2]]; // add cubic bezier pt[0] pt[3], control points pt[1] , pt[2]      [self draw2];  pts[1] = pts[4];         ctr = 1;            }             lastpoint = currentpoint;     }  - (void)touchesended:(nsset *)touches withevent:(uievent *)event     {     [path removeallpoints];            ctr = 0;            uigraphicsbeginimagecontext(self.tempimage.frame.size);      [self.imagesview.image drawinrect:cgrectmake(0,0, self.imagesview.frame.size.width, self.imagesview.frame.size.height) blendmode:kcgblendmodenormal alpha:1.0];     [self.tempimage.image drawinrect:cgrectmake(0,0, self.tempimage.frame.size.width, self.tempimage.frame.size.height) blendmode:kcgblendmodenormal alpha:a];      self.imagesview.image = uigraphicsgetimagefromcurrentimagecontext();            self.tempimage.image = nil;            uigraphicsendimagecontext();   }   - (void)draw2 { uigraphicsbeginimagecontext(self.tempimage.frame.size);         [self.tempimage.image drawinrect:cgrectmake(0, 0, self.tempimage.frame.size.width, self.tempimage.frame.size.height)];  if ([pencilstring isequaltostring:@"red"]) { 

//i assign preexisting .png (redtextureimage.png) colorwithpatternimage , draw it

brushimage = [uiimage imagenamed:@"redtextureimage.png];                  [[uicolor colorwithpatternimage:brushimage]setstroke];             }  cgcontextsetblendmode(uigraphicsgetcurrentcontext(),kcgblendmodenormal);             [path stroke];          } 

//and sets alpha

 self.tempimage setalpha:a];  uigraphicsendimagecontext();  } 

so can draw stroke or line across tempview when touchesmoved

and have saved onto imagesview on touchesend @ whatever alpha choose.

problem

what want take imagesview.image , save png image , load colorwithpatternimage, changing alpha @ will. can draw line across original drawing more transparent , change alpha , have different line of different transparency.

how save uiimageview.image .png image used colorpatternimage?

i have image illustrate can't see how upload it.

so figured out:

in touchesbegan made brushimage = self.imagesview.image;

then in touchesmoved used code erase stroke form imagesview , (draw2) redraw using colorwithpatterncolor brushimage instead of using blendmodenormal used blendmodecopy.

and works way want.