Wednesday, April 18, 2012

How to create a transparent background in CGContext ?



    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGRect a=self.frame;
    a.origin.x=0;
    a.origin.y=0;
    CGContextSetBlendMode(context, kCGBlendModeClear);
    CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);    
    CGContextAddRect(context, a);
    CGContextFillPath(context);
    CGContextRestoreGState(context);



Don't forget to add the background color as clear color.



- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self setBackgroundColor:[UIColor clearColor]];
    }
    return self;
}




2 comments:

  1. I Will Remove Background Of Your Image,Product,Logo And Crop It My Service :

    1.BACKGROUND REMOVING/CHANGING
    2.Transparent background
    3.Jpg/Png background
    4.Amazone Product Background removing.
    5.Furniture Background removing.
    6.Logo Background removing.
    Or any other images or products Background removing.

    Extra Service,

    1.Re-sizing/Cropping
    2.Convert your photo into any format
    3.Removing unwanted objects
    4.Remove wrinkles and blemishes
    5.Color correction
    6.Photo merging
    7.Shadow effects

    MANY MORE

    If your Order requirement is NOT listed above, just contact me before ordering. I will give you good solution.

    I will provide you,

    Unlimited revisions
    100% customer satisfaction
    100% Money back granted

    Please Knock me First before order.

    ReplyDelete