Revision control
Copy as Markdown
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
import UIKit
extension CGRect {
public init(width: CGFloat, height: CGFloat) {
self.init(x: 0, y: 0, width: width, height: height)
}
public init(size: CGSize) {
self.init(origin: .zero, size: size)
}
public var center: CGPoint {
get {
return CGPoint(x: size.width / 2, y: size.height / 2)
}
set {
self.origin = CGPoint(x: newValue.x - size.width / 2, y: newValue.y - size.height / 2)
}
}
}