Return a subimage from a UIImage

后端 未结 3 769
不知归路
不知归路 2020-12-08 11:45

I want to grab a subimage from a UIImage. I\'ve looked around for a similar question, to no avail.

I know the range of pixels I want to grab - how can I return th

3条回答
  •  鱼传尺愫
    2020-12-08 12:01

    Updated @donkim answer for swift 3:

        let fromRect=CGRect(x:0,y:0,width:320,height:480)
        let drawImage = image.cgImage!.cropping(to: fromRect)
        let bimage = UIImage(cgImage: drawImage!)
    

提交回复
热议问题