@@ -294,17 +294,15 @@ enum DisplayScale: CGFloat, Comparable {
294
294
}
295
295
}
296
296
297
- /// Returns the provided value scaled to the current display width relative to self. The result
298
- /// is always rounded in the direction of the scaling.
297
+ /// Returns the provided value scaled to the current display width relative to self.
299
298
/// - parameter value: The value to scale.
300
299
func scale( _ value: CGFloat ) -> CGFloat {
301
300
guard self != . any else { return value }
302
- let scaled = value * ( min ( UIScreen . main. bounds. width, DisplayScale . maxScaling. rawValue) / rawValue)
303
- return scaled . rounded ( scaled < value ? . down : . up )
301
+ let scale = min ( UIScreen . main. bounds. width, DisplayScale . maxScaling. rawValue) / rawValue
302
+ return value * scale
304
303
}
305
304
306
- /// Returns the provided value scaled to the current display size relative to self. The result
307
- /// is always rounded in the direction of the scaling.
305
+ /// Returns the provided value scaled to the current display size relative to self.
308
306
///
309
307
/// The display's width and height are considered, the latter of which relative to the maximum
310
308
/// possible height for the width class. The smallest scale factor is used to scale the result.
@@ -313,8 +311,8 @@ enum DisplayScale: CGFloat, Comparable {
313
311
guard self != . any else { return value }
314
312
let widthScale = min ( UIScreen . main. bounds. width, DisplayScale . maxScaling. rawValue) / rawValue
315
313
let heightScale = min ( UIScreen . main. bounds. height, DisplayScale . maxScaling. maxHeight) / maxHeight
316
- let scaled = value * min ( widthScale, heightScale)
317
- return scaled . rounded ( scaled < value ? . down : . up )
314
+ let scale = abs ( 1 - widthScale) > abs ( 1 - heightScale) ? widthScale : heightScale
315
+ return value * scale
318
316
}
319
317
320
318
static func < ( lhs: DisplayScale , rhs: DisplayScale ) -> Bool {
0 commit comments