absolute or relative in CGRect#center
colinta opened this issue · 1 comments
I was working on a few new methods in CGRect
(#{top,center,bottom}_{left,center,right}
, eg top_left
and bottom_center
), and realized that the behavior of these methods – as I had written them – was different from the way the center
method was written, because I had ignored the absolute
argument (I was returning absolute values).
I was wondering if you have found the default behavior of center
(to return the relative value) to be of greater use than returning the absolute position. I see some benefit to both, but I'm leaning towards returning the absolute position, because usually when I work with a rect it is in the context of having a frame
and bounds
to work with, and so if I wanted relative coordinates I would use bounds
. That said, returning the relative point has the advantage that you can easily position things inside a frame
, even when the bounds is moving (e.g. inside a UIScrollView
- the contentOffset
affects the bounds
).
Returning the absolute value by default means it is easy to position rects relative to each other rather than relative to the parent.
Give it some thought, I'll push my code up using the current default, but I wanted to make sure it was given some extra thought before just plowing ahead.
Okay, I pushed up these changes, and I'm feeling much better about the current state of affairs. Check out the README on my fork, and the recent commits. https://github.com/colinta/geomotion#relative-vs-absolute