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:

enter image description here

desired:

enter image description here

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

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -