2012-02-25 73 views
1

我想在我的iPhone應用程序中應用不同的邊框圖像。我從相機捕捉圖像。現在我有一些不同的邊框,我想將該邊框應用於圖像。我怎麼做 ??iphone中的邊框圖像

回答

2
- (UIImage*)imageWithBorderFromImage:(UIImage*)source 
{ 
    CGSize size = [source size]; 
    UIGraphicsBeginImageContext(size); 
    CGRect rect = CGRectMake(0, 0, size.width, size.height); 
    [source drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0]; 

    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetRGBStrokeColor(context, 1.0, 0.5, 1.0, 1.0); 
    CGContextStrokeRect(context, rect); 
    UIImage *testImg = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return testImg; 

}

+0

感謝aadil哈菲茲 – DipakSonara 2012-02-27 08:53:58