我想知道是否有任何方法可以将一个 CGRect 与另一个 CGRect 组合起来以获得一个新的 CGRect。 swift 是否有任何预设功能来执行此操作,或者是否有其他方法可以实现此目的?
let rect1 = CGRect(x: 0, y: 0, width: 100, height: 100)
let rect2 = CGRect(x: 40, y: 40, width: 150, height: 150)
let union = rect1.union(rect2) // {x 0 y 0 w 190 h 190}
更多内容请参见:
- https://developer.apple.com/documentation/coregraphics/cggeometry https://developer.apple.com/documentation/coregraphics/cggeometry
- https://developer.apple.com/documentation/coregraphics/cgrect https://developer.apple.com/documentation/coregraphics/cgrect
- https://developer.apple.com/documentation/coregraphics/cgrect/1455837-union https://developer.apple.com/documentation/coregraphics/cgrect/1455837-union
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)