We need to have a degree of CIImage or CGRect in which we want to create a solid border. Then we can draw the CIImage, forming a solid line in the specified area, and repeat the steps three more times for different positions to draw a full solid rectangle. Below is a snippet of code that will draw a straight solid line above the specified area.
CIImage *overlay1 = [CIImage imageWithColor:[CIColor colorWithRed:255/255.f green:0/255.f blue:0/255.f alpha:1.00f]]; overlay1 = [overlay1 imageByCroppingToRect:image.extent]; overlay1 = [overlay1 imageByApplyingFilter:@"CIPerspectiveTransformWithExtent" withInputParameters:@{@"inputExtent":[CIVector vectorWithCGRect:image.extent],@"inputTopLeft":[CIVector vectorWithCGPoint:CGPointMake(topLeft.x - 5, topLeft.y + 5)],@"inputTopRight":[CIVector vectorWithCGPoint:CGPointMake(topRight.x + 5, topRight.y + 5)],@"inputBottomLeft":[CIVector vectorWithCGPoint:CGPointMake(topLeft.x - 5, topLeft.y )],@"inputBottomRight":[CIVector vectorWithCGPoint:CGPointMake(topRight.x + 5, topRight.y ) ]}]; overlay = [ overlay1 imageByCompositingOverImage:overlay];
I kept the width for 5 pixels. topLeft, topRight .... are the appropriate CGPoint for the position. For a full rectangle, you'll also need bottomLeft and bottomRight.
Overlay is the original CIImage.
source share