Created
September 21, 2022 08:56
-
-
Save anz-ryu/303d3e8dad647794deccfda6ad37f7a5 to your computer and use it in GitHub Desktop.
CGRectを拡大する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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