| 1234567891011121314151617181920212223242526272829 |
- //
- // CGPoint.swift
- // Naterade
- //
- // Created by Nathan Racklyeft on 2/29/16.
- // Copyright © 2016 Nathan Racklyeft. All rights reserved.
- //
- import UIKit
- extension CGPoint {
- /**
- Rounds the coordinates to whole-pixel values
- - parameter scale: The display scale to use. Defaults to the main screen scale.
- */
- mutating func makeIntegralInPlaceWithDisplayScale(_ scale: CGFloat = 0) {
- var scale = scale
- // It's possible for scale values retrieved from traitCollection objects to be 0.
- if scale == 0 {
- scale = UIScreen.main.scale
- }
- x = round(x * scale) / scale
- y = round(y * scale) / scale
- }
- }
|