The simplest way to resize an UIImage?

前端 未结 30 2609
迷失自我
迷失自我 2020-11-21 22:38

In my iPhone app, I take a picture with the camera, then I want to resize it to 290*390 pixels. I was using this method to resize the image :

UIImage *newI         


        
30条回答
  •  醉话见心
    2020-11-21 22:48

    Swift 2.0 :

    let image = UIImage(named: "imageName")
    let newSize = CGSize(width: 10, height: 10)
    
    UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
    image?.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height))
    let imageResized = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    

提交回复
热议问题