i'm using uicollectionview lay out bunch of cells sectioned first letter of title. each cell should have thin border around it, , section headers should have borders above , below. here's current prototype:
i achieve current appearance following rules:
- stroke right , bottom edge of each cell.
- stroke bottom edge of each section heading.
this close want, there 2 defects:
- if line before section heading isn't full, border along top of heading stops short of right edge of screen.
- it's not visible in screenshot, if line is full, right border of last cell in line still drawn, looks little odd against edge of screen.
my best idea fix somehow tell each cell if it's in last row of section or last cell in row; cell turn off offending borders, section headings draw top border bottom, , hunky-dory. don't know how achieve that, though.
any thoughts on how manage that, or way i'm going for? i'm using uicollectionviewflowlayout.
i ended subclassing uicollectionviewflowlayout
, applying several heuristics after flow layout had calculated attributes each cell:
- if
center.y
equalcenter.y
of last item in section, cell in last row of section. - if
cgrectgetmaxy(frame)
equalcgrectgetmaxy(self.collectionview.bounds)
, cell agains right edge of collection view.
i stored results of these calculations in subclass of uicollectionviewlayoutattributes
, , wrote uicollectionviewcell
subclass -applylayoutattributes:
method adjust borders background view draws based on additional properties.
i've put whole mess fairly enormous gist can see did. happy hacking.
Comments
Post a Comment