iphone - CGContextDrawImage when shifting x offset -


so have following code:

 cgcontextdrawimage(context, cgrectmake(100, 0, 220, self.image.size.height), self.image.cgimage); 

basically asking cg draw image 100 px right.. works fine.. left of image see white background. how change background other color? want black blackground

before drawing image, fill rect desired color:

cgcontextsetfillcolorwithcolor(context, [uicolor blackcolor].cgcolor); cgcontextfillrect(context, cgrectmake(0, 0, self.image.size.width + 100, self.image.size.height)); //i suppose rect's width as image's width +100 //then draw image cgcontextdrawimage(context, cgrectmake(100, 0, 220, self.image.size.height), self.image.cgimage); 

note: make sure rect's you're drawing width @ least image's width + 100


Comments