Created
May 15, 2014 10:59
-
-
Save davidoram/b7242c79733e92a6d171 to your computer and use it in GitHub Desktop.
Custom UITableViewCell in rubymotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomCell < UITableViewCell | |
def location=(value) | |
@locationLabel.text = value | |
end | |
def ringName=(value) | |
@ringNameLabel.text = value | |
end | |
def dateTime=(value) | |
@dateLabel.text = DateUtil.instance.short_date_formatter.stringFromDate(value) | |
@timeLabel.text = DateUtil.instance.hh_formatter.stringFromDate(value) | |
end | |
def alertCount=(value) | |
@alertCountLabel.text = value.to_s | |
end | |
#def drawRect(rect) | |
# super | |
# puts "Width: #{self.frame.size.width}, Height #{self.frame.size.height}" | |
#end | |
def createLabels | |
@locationLabel = UILabel.alloc.init | |
@locationLabel.textAlignment = UITextAlignmentLeft | |
@locationLabel.font = UIFont.systemFontOfSize(10) | |
@ringNameLabel = UILabel.alloc.init | |
@ringNameLabel.textAlignment = UITextAlignmentLeft | |
@ringNameLabel.font = UIFont.systemFontOfSize(10) | |
@dateLabel = UILabel.alloc.init | |
@dateLabel.textAlignment = UITextAlignmentLeft | |
@dateLabel.font = UIFont.systemFontOfSize(10) | |
@timeLabel = UILabel.alloc.init | |
@timeLabel.textAlignment = UITextAlignmentLeft | |
@timeLabel.font = UIFont.systemFontOfSize(10) | |
@alertCountLabel = UILabel.alloc.init | |
@alertCountLabel.textAlignment = UITextAlignmentLeft | |
@alertCountLabel.font = UIFont.systemFontOfSize(30) | |
self.contentView.addSubview(@locationLabel) | |
self.contentView.addSubview(@ringNameLabel) | |
self.contentView.addSubview(@dateLabel) | |
self.contentView.addSubview(@timeLabel) | |
self.contentView.addSubview(@alertCountLabel) | |
end | |
def layoutSubviews | |
super | |
contentRect = self.contentView.bounds | |
boundsX = contentRect.origin.x | |
boundsY = contentRect.origin.y | |
@locationLabel.frame = CGRectMake(15, 5, 100, 20) | |
@ringNameLabel.frame = CGRectMake(15, 25, 100, 20) | |
@dateLabel.frame = CGRectMake(120, 5, 100, 20) | |
@timeLabel.frame = CGRectMake(120, 25, 100, 20) | |
@alertCountLabel.frame = CGRectMake(280, 2, 100, 40) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment