Skip to content

Instantly share code, notes, and snippets.

@anz-ryu
Created September 21, 2022 08:56
Show Gist options
  • Save anz-ryu/303d3e8dad647794deccfda6ad37f7a5 to your computer and use it in GitHub Desktop.
Save anz-ryu/303d3e8dad647794deccfda6ad37f7a5 to your computer and use it in GitHub Desktop.
CGRectを拡大する
// CGRectを拡大する
extension CGRect {
func enlarge(rate :CGFloat) -> CGRect {
if rate > 1 {
let distanceRate = (rate - 1) / 2
let distanceX = -width * distanceRate
let distanceY = -height * distanceRate
return insetBy(dx: distanceX, dy: distanceY)
}
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment