class Formotion::RowType::ButtonRow
Public Instance Methods
build_cell(cell)
click to toggle source
Does a clever little trick to override layoutSubviews
for just this one UITableViewCell object, in order to center it's labels horizontally.
# File lib/formotion/row_type/button.rb, line 13 def build_cell(cell) cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue cell.swizzle(:layoutSubviews) do def layoutSubviews old_layoutSubviews center = lambda {|frame, dimen| ((self.frame.size.send(dimen) - frame.size.send(dimen)) / 2.0) } self.textLabel.center = CGPointMake(self.frame.size.width / 2, self.textLabel.center.y) self.detailTextLabel.center = CGPointMake(self.frame.size.width / 2, self.detailTextLabel.center.y) end end nil end
layoutSubviews()
click to toggle source
# File lib/formotion/row_type/button.rb, line 16 def layoutSubviews old_layoutSubviews center = lambda {|frame, dimen| ((self.frame.size.send(dimen) - frame.size.send(dimen)) / 2.0) } self.textLabel.center = CGPointMake(self.frame.size.width / 2, self.textLabel.center.y) self.detailTextLabel.center = CGPointMake(self.frame.size.width / 2, self.detailTextLabel.center.y) end