我希望在Swift中编写一个函数,该函数接受图片并裁剪除中间一条细长的水平线以外的所有内容。我不想保留宽高比。
这是我目前拥有的代码,但它不能按照我的想法工作。我只想保留从y = 276到y = 299的像素。
这是我目前拥有的代码,但它不能按照我的想法工作。我只想保留从y = 276到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
}