【发布时间】:2012-02-25 06:08:34
【问题描述】:
我想为我的 iphone 应用程序中的图像应用不同的边框。我正在从相机捕捉图像。现在我有一些不同的边框,我想将该边框应用于图像。我怎么做 ??
【问题讨论】:
标签: iphone ios uiimageview
我想为我的 iphone 应用程序中的图像应用不同的边框。我正在从相机捕捉图像。现在我有一些不同的边框,我想将该边框应用于图像。我怎么做 ??
【问题讨论】:
标签: iphone ios uiimageview
- (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;
}
【讨论】: