我已引用此链接How do I capture a zoomed UIImageView inside of a Scrollview to crop?
我想在android上做同样的事情,如下面的截图所示。我该怎么做呢?
最佳答案
func getzoomedimage()->uiimage{
//Calculate the required area from the scrollview
var visibleRect = CGRect()
let scale: CGFloat = CGFloat(1.0 / scrollViewGallery.zoomScale)
visibleRect.origin.x = scrollViewGallery.contentOffset.x * scale
visibleRect.origin.y = scrollViewGallery.contentOffset.y * scale
visibleRect.size.width = scrollViewGallery.bounds.size.width * scale
visibleRect.size.height = scrollViewGallery.bounds.size.height * scale
let cgImg: CGImage? = imgView.image?.cgImage?.cropping(to: visibleRect)
let croppedImg = UIImage(cgImage: cgImg!)
return croppedImg
}
关于android - 如何在Scrollview中捕获缩放的UIImageView以便在Android中裁剪?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21623589/