Skip to content

Instantly share code, notes, and snippets.

@Zeta611
Last active January 18, 2021 13:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zeta611/4153f107af2d3835e873d412b9e6a60c to your computer and use it in GitHub Desktop.
Save Zeta611/4153f107af2d3835e873d412b9e6a60c to your computer and use it in GitHub Desktop.
[CGPoint+offsetBy] Extends `offsetBy` method to `CGPoint`. #extension #iOS
//
// CGPoint+offsetBy.swift
//
// Created by Jay Lee on 29/01/2019.
// Copyright © 2019 Jay Lee <jaeho.lee@snu.ac.kr>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
//
import UIKit
extension CGPoint {
/// Retuns the point which is an offset of an existing point.
///
/// - Parameters:
/// - dx: The x-coordinate offset to apply.
/// - dy: The y-coordinate offset to apply.
///
/// - Returns:
/// A new point which is an offset of an existing point.
func offsetBy(dx: CGFloat, dy: CGFloat) -> CGPoint {
return CGPoint(x: x + dx, y: y + dy)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment