We have an array of CGPoints:
let points = [(1234.0, 1053.0), (1241.0, 1111.0), (1152.0, 1043.0)]
What I'm trying to do is get the CGPoint with the highest x value and the one with the highest y value in the array. I will be using these points to create a CGRect:
extension CGRect {
init(p1: CGPoint, p2: CGPoint) {
self.init(x: min(p1.x, p2.x),
y: min(p1.y, p2.y),
width: abs(p1.x - p2.x),
height: abs(p1.y - p2.y))
}
}
I know there a way to get max and min values in an array by doing something like this:
points.min()
points.max()
but these don't seem to work since its an array of CGPoints. Is it possible to get these values from the array?