33 lines
655 B
Swift
33 lines
655 B
Swift
//
|
|
// CGPoint+Utils.swift
|
|
// SBrowser
|
|
//
|
|
// Created by James Magahern on 7/23/20.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension CGRect
|
|
{
|
|
var center: CGPoint {
|
|
get {
|
|
return CGPoint(x: size.width / 2.0, y: size.height / 2.0)
|
|
}
|
|
}
|
|
|
|
public func avoiding(verticalInsets insets: UIEdgeInsets) -> CGRect {
|
|
var rect = self
|
|
rect.origin.y += insets.top
|
|
rect.size.height -= insets.top
|
|
|
|
return rect
|
|
}
|
|
|
|
public func centeredY(inRect: CGRect) -> CGRect {
|
|
var rect = self
|
|
rect.origin.y = CGRound((inRect.height - rect.height) / 2.0)
|
|
|
|
return rect
|
|
}
|
|
}
|