Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
That is my perform as extension UIImage
:
func scaledWithMaxWidthOrHeightValue(worth: CGFloat, spacing: CGFloat = 0, backgroundColor: UIColor = .clear, line: Bool = false, printing: Bool = false) -> UIImage? {
let width = self.measurement.width
let peak = self.measurement.peak
if width < worth && peak < worth {
return self
}
let ratio = width/peak
var newWidth = worth
var newHeight = worth
if ratio > 1 {
newWidth = min(width, worth)
newHeight = peak * (newWidth/width)
} else {
newHeight = min(peak, worth)
newWidth = width * (newHeight/peak)
}
let rangeWidth = newWidth + spacing * 2
let rangeHeight = newHeight + spacing * 2
UIGraphicsBeginImageContextWithOptions(CGSize(width: rangeWidth, peak: rangeHeight), false, 0)
let ctx = UIGraphicsGetCurrentContext()
backgroundColor.setFill()
ctx?.fill(CGRect(x: 0, y: 0, width: rangeWidth, peak: rangeHeight))
draw(in: CGRect(x: spacing, y: spacing, width: newWidth, peak: newHeight))
if printing {
let size: CGFloat = 7
let stroke: CGFloat = 0.5
ctx?.setFillColor(UIColor.purple.cgColor)
ctx?.addRect(CGRect(x: spacing, y: 0, width: stroke, peak: size))
ctx?.addRect(CGRect(x: 0, y: spacing, width: size, peak: stroke))
ctx?.addRect(CGRect(x: rangeWidth - spacing, y: 0, width: stroke, peak: size))
ctx?.addRect(CGRect(x: rangeWidth - 8, y: spacing, width: size, peak: stroke))
ctx?.addRect(CGRect(x: rangeWidth - size, y: rangeHeight - spacing, width: size, peak: stroke))
ctx?.addRect(CGRect(x: rangeWidth - spacing, y: rangeHeight - size, width: stroke, peak: size))
ctx?.addRect(CGRect(x: spacing, y: rangeHeight - size, width: stroke, peak: size))
ctx?.addRect(CGRect(x: 0, y: rangeHeight - spacing, width: size, peak: stroke))
ctx?.drawPath(utilizing: .fill)
}
if line {
ctx?.setStrokeColor(UIColor.purple.cgColor)
ctx?.setLineWidth(0.5)
ctx?.addEllipse(in: CGRect(x: spacing, y: spacing, width: newWidth, peak: newHeight))
ctx?.drawPath(utilizing: .stroke)
}
let picture = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return picture
}
And in ios 16 it seems to be like this:
and earlier than the replace it was:
Please, inform me the place is the essential place that’s inflicting the issue?
UPDATE:
Downvoting doesnt change something, as a result of it’s query like every other.
[ad_2]