Sha256: ef5ae453103f2d181238c6ae8e4c27b89a400a46286390553013a2a9b17ca04c
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
class PostTableViewCell < UITableViewCell attr_accessor :post def initWithStyle(style, reuseIdentifier:reuseIdentifier) super self.textLabel.adjustsFontSizeToFitWidth = true self.textLabel.textColor = UIColor.darkGrayColor self.detailTextLabel.font = UIFont.systemFontOfSize 12 self.detailTextLabel.numberOfLines = 0 self.selectionStyle = UITableViewCellSelectionStyleGray self end def post=(post) @post = post self.textLabel.text = self.post.user.username self.detailTextLabel.text = self.post.text self.imageView.url = {url: self.post.user.avatar_url.to_url, placeholder: UIImage.imageNamed("profile-image-placeholder")} self.setNeedsLayout @post end def self.heightForCellWithPost(post) sizeToFit = post.text.sizeWithFont(UIFont.systemFontOfSize(12), constrainedToSize: CGSizeMake(220, Float::MAX), lineBreakMode:UILineBreakModeWordWrap) return [70, sizeToFit.height + 45].max end def layoutSubviews super self.imageView.frame = CGRectMake(10, 10, 50, 50); self.textLabel.frame = CGRectMake(70, 10, 240, 20); detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0, 25); detailTextLabelFrame.size.height = self.class.heightForCellWithPost(self.post) - 45 self.detailTextLabel.frame = detailTextLabelFrame end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
afmotion-0.0.1 | examples/AppDotNet/app/post_table_view_cell.rb |