I want to write a function in Swift that takes an image and crops out everything except a thin horizontal like in the middle. I don't want to preserve the aspect ratio.
This is what I have so far but it doesn't work the way I want it to. I want to only preserve the pixels from y=276 to y=299.
func cropImageToBars(image: UIImage) -> UIImage {
let rect = CGRectMake(0, 200, image.size.width, 23)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
image.drawInRect(rect)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}