MsgListCell.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // MsgListCell.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/2/2.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "MsgListCell.h"
  9. @implementation MsgListCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  15. {
  16. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  17. if (self)
  18. {
  19. _dateBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  20. _dateBtn.frame = CGRectMake(kSize.width/2 - 80, 20, 180, 20);
  21. _dateBtn.backgroundColor = [UIColor blackColor];
  22. _dateBtn.alpha = .3;
  23. _dateBtn.userInteractionEnabled = NO;
  24. [self addSubview:_dateBtn];
  25. _headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 45, 50, 50)];
  26. [self addSubview:_headImgView];
  27. //因为气泡的大小不合适,所以需要在添加图片前 先修改图片
  28. //拉伸图片
  29. UIImage * image = [UIImage imageNamed:@"bubble"];
  30. //计算左边端盖
  31. NSInteger leftCap = image.size.width * 0.5f;
  32. //计算顶部端盖
  33. NSInteger topCap = image.size.height * 0.5f;
  34. //拉伸imageView的大小 需要传入两个值 左端盖 和上端盖
  35. image = [image stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
  36. //气泡背景
  37. _backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(65, 45, kSize.width - 100, 50)];
  38. [_backImageView setImage:image];
  39. [self addSubview:_backImageView];
  40. //文本消息
  41. _messageContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(85, 50, kSize.width - 125, 40)];
  42. [_messageContentLabel setNumberOfLines:0];
  43. [_messageContentLabel setFont:[UIFont scaleSize:17]];
  44. [self addSubview:_messageContentLabel];
  45. }
  46. return self;
  47. }
  48. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  49. [super setSelected:selected animated:animated];
  50. // Configure the view for the selected state
  51. }
  52. @end