Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. func colorForIndex(index: Int) -> UIColor
  2. {
  3.  
  4. let itemCount = stnRepos.count - 1
  5. let color = (CGFloat(index) / CGFloat(itemCount)) * 0.6
  6. return UIColor(red: 0.80, green: color, blue: 0.0, alpha: 1.0)
  7. }
  8.  
  9. func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
  10. forRowAtIndexPath indexPath: NSIndexPath)
  11. {
  12. var count = stnRepos.count
  13. for (var i = 0; i<=count; i++)
  14. {
  15. if (i % 2 == 0)
  16. {
  17. cell.backgroundColor = colorForIndex(indexPath.row)
  18. println(i)
  19. }
  20. }
  21. }
  22.  
  23. func colorForIndex(index: Int) -> UIColor
  24. {
  25. let itemCount = stnRepos.count - 1
  26. let color = (CGFloat(index) / CGFloat(itemCount)) * 0.6
  27. return UIColor(red: 0.80, green: color, blue: 0.0, alpha: 1.0)
  28. }
  29.  
  30. func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
  31. forRowAtIndexPath indexPath: NSIndexPath)
  32. {
  33. if (indexPath.row % 2 == 0)
  34. {
  35. cell.backgroundColor = colorForIndex(indexPath.row)
  36. } else {
  37. cell.backgroundColor = UIColor.whiteColor()()
  38. }
  39. }
  40.  
  41. - tableView:willDisplayCell:forTableColumn:row:
  42.  
  43. func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
  44. forRowAtIndexPath indexPath: NSIndexPath)
  45. {
  46. if (indexPath.row % 2 == 0)
  47. {
  48. cell.backgroundColor = colorForIndex(indexPath.row)
  49. }
  50. else
  51. {
  52. cell.backgroundColor = UIColor.whiteColor()
  53. }
  54. }
  55.  
  56. func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
  57. forRowAtIndexPath indexPath: NSIndexPath)
  58. {
  59. if (indexPath.row % 2 == 0)
  60. {
  61. cell.backgroundColor = UIColor.gray
  62. } else {
  63. cell.backgroundColor = UIColor.white
  64. }
  65.  
  66. cell.backgroundColor = colorForIndex(indexPath.row)
  67.  
  68. cell.contentView.backgroundColor = colorForIndex(indexPath.row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement