12345678910111213141516171819202122232425262728293031323334 |
- import Foundation
- extension UIImage {
-
-
-
-
-
-
-
-
- func scaledImage(atPoint point: CGPoint, scaleFactor: CGFloat, targetSize size: CGSize) -> UIImage? {
- guard let cgImage = self.cgImage else {
- return nil
- }
-
- let scaledSize = CGSize(width: size.width / scaleFactor, height: size.height / scaleFactor)
-
- guard let croppedImage = cgImage.cropping(to: CGRect(x: point.x - scaledSize.width / 2.0, y: point.y - scaledSize.height / 2.0, width: scaledSize.width, height: scaledSize.height)) else {
- return nil
- }
-
- return UIImage(cgImage: croppedImage)
- }
-
- }
|