layout - Counter-clockwise iOS CircleLayout -
i'm using modified version of apple's circlelayout wwdc found here: https://github.com/mpospese/circlelayout.
my current code draws first element @ top , lays out rest in clockwise fashion. how can use code layout starts first element @ top , draws next elements counter-clockwise along path? trigonometry bit rusty.
i believe portion of code needs changing is:
- (uicollectionviewlayoutattributes *)layoutattributesforitematindexpath:(nsindexpath *)path { uicollectionviewlayoutattributes* attributes = [uicollectionviewlayoutattributes layoutattributesforcellwithindexpath:path]; attributes.size = cgsizemake(item_size, item_size); attributes.center = cgpointmake(_center.x + _radius * cosf(2 * path.item * m_pi / _cellcount - m_pi / 2), _center.y + _radius * sinf(2 * path.item * m_pi / _cellcount - m_pi / 2)); return attributes; }
current:
desired:
replacing angle negative value changes orientation. in case
attributes.center = cgpointmake(_center.x + _radius * cosf(-2 * path.item * m_pi / _cellcount - m_pi / 2), _center.y + _radius * sinf(-2 * path.item * m_pi / _cellcount - m_pi / 2));
should trick.
Comments
Post a Comment