使用CIImage添加纯色边框

fri*_*ldi 6 iphone objective-c ios

我正在寻找一种方法,使用Core Image为现有图像添加纯色边框.我找到了过滤器列表参考,但没有人可以做到.

救命 !!

jha*_*ott 1

这并不完全是您所问的问题,但如果您只想显示带有边框的图像(而不是实际在其上绘制边框),那么可能会更好...

您可以使用它向任何...CALayer添加边框(以及圆角、阴影等)。UIView

// imgView is an instance of UIImageView, but this works with any UIView
imgView.layer.borderWidth = 2.0f;
imgView.layer.borderColor = [[UIColor blackColor] CGColor];
Run Code Online (Sandbox Code Playgroud)

您还需要#import <QuartzCore/QuartzCore.h>链接到 QuartzCore 框架才能使其工作。