FMMainTableViewCell.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // FMMainTableViewCell.m
  3. // FreeMusic
  4. //
  5. //
  6. #import "FMMainTableViewCell.h"
  7. #import "FMPAImageView.h"
  8. #import "UIView+Additions.h"
  9. #import "UIImageView+WebCache.h"
  10. #import "FMSingerModel.h"
  11. @implementation FMMainTableViewCell
  12. -(void)setModel:(FMSingerModel *)model_
  13. {
  14. _model = model_;
  15. [headerImageView setImageWithURL:[NSURL URLWithString:_model.avatar_big] placeholderImage:[UIImage imageNamed:@"headerImage"]];
  16. nameLabel.text = _model.name;
  17. if ([_model.company length]!=0) {
  18. titleLabel.text = _model.company;
  19. }else{
  20. titleLabel.text = @"<无信息>";
  21. }
  22. }
  23. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  24. {
  25. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  26. if (self) {
  27. // Initialization code
  28. self.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
  29. headerImageView = [[FMPAImageView alloc] initWithFrame:CGRectMake(5, 5, 60, 60)];
  30. [self.contentView addSubview:headerImageView];
  31. nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(headerImageView.size.width+headerImageView.origin.x+5, headerImageView.origin.y, self.contentView.size.width-headerImageView.size.width-headerImageView.origin.x-30, 30)];
  32. nameLabel.font = [UIFont boldSystemFontOfSize:16.0f];
  33. [self.contentView addSubview:nameLabel];
  34. titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameLabel.origin.x, nameLabel.size.height+nameLabel.origin.y+5, nameLabel.size.width, nameLabel.size.height-10)];
  35. titleLabel.font = [UIFont systemFontOfSize:13.0f];
  36. titleLabel.textColor = [UIColor lightGrayColor];
  37. [self.contentView addSubview:titleLabel];
  38. }
  39. return self;
  40. }
  41. - (void)awakeFromNib
  42. {
  43. // Initialization code
  44. }
  45. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  46. {
  47. [super setSelected:selected animated:animated];
  48. // Configure the view for the selected state
  49. }
  50. @end