UIGraphicsBeginImageContext with parameters

后端 未结 5 1348
忘了有多久
忘了有多久 2021-02-19 19:06

I am taking a screenshot in my application. I am able to take the screenshot.

Now I want to take the screenshot by specifying the x and y coordinate. Is that possible?

5条回答
  •  梦谈多话
    2021-02-19 19:34

    Here is Swift version

    //Capture Screen
    func capture()->UIImage {
    
        UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, UIScreen.mainScreen().scale)
        self.view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image
    
    }
    

提交回复
热议问题