Skip to content

Instantly share code, notes, and snippets.

@arkan
Created May 28, 2013 13:53
Show Gist options
  • Save arkan/5662905 to your computer and use it in GitHub Desktop.
Save arkan/5662905 to your computer and use it in GitHub Desktop.
class MyCustomCell < UITableViewCell
# This method is used by ProMotion to instantiate cells.
def initWithStyle(style_name, reuseIdentifier: reuseIdentifier)
super
stylish
self
end
# A delegate method when the user clicks the Row(it's blue by default)
def setHighlighted(highlighted, animated: animated)
if highlighted
self.backgroundColor = UIColor.redColor
else
self.backgroundColor = UIColor.whiteColor
end
end
def stylish
self.backgroundColor = UIColor.whiteColor
self.selectionStyle = UITableViewCellSelectionStyleNone
end
end
class MyAwesomeScreen < ProMotion::TableScreen
def on_init
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone #To remove the cell's separator
self.tableView.backgroundColor = UIColor.yellowColor
end
def table_data
[{
cells: (1..100).to_a.collect {|c|
{
title: "Cell at row #{c}",
cell_identifier: "MyCustomCellIdentifier",
cell_class: MyCustomCell,
height: 70,
}
}
}]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment