向UIImage添加图像边框
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了向UIImage添加图像边框相关的知识,希望对你有一定的参考价值。
Adds a fine border to a UIImage.
- (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; }
以上是关于向UIImage添加图像边框的主要内容,如果未能解决你的问题,请参考以下文章