Created
December 20, 2016 07:51
-
-
Save randhirraj3130/f95d718162fca8258e888bf7921086b0 to your computer and use it in GitHub Desktop.
how to crop image in swift 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView | |
{ | |
func getCropedImage(frame: CGRect) -> UIImage | |
{ | |
UIGraphicsBeginImageContextWithOptions(frame.size, false, 0) | |
drawHierarchy(in: CGRect(x: -frame.origin.x, y:-frame.origin.y, width: self.bounds.size.width, height: self.bounds.size.height), afterScreenUpdates: true) | |
let snapshotImage = UIGraphicsGetImageFromCurrentImageContext()! | |
UIGraphicsEndImageContext() | |
return snapshotImage | |
} | |
} | |
// FullImage.image = FullView.getCropedImage(frame: CropView.frame) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment