1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // MsgListCell.m
- // jiaPeiC
- //
- // Created by apple on 16/2/2.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "MsgListCell.h"
- @implementation MsgListCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self)
- {
- _dateBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- _dateBtn.frame = CGRectMake(kSize.width/2 - 80, 20, 180, 20);
- _dateBtn.backgroundColor = [UIColor blackColor];
- _dateBtn.alpha = .3;
- _dateBtn.userInteractionEnabled = NO;
- [self addSubview:_dateBtn];
-
- _headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 45, 50, 50)];
- [self addSubview:_headImgView];
-
- //因为气泡的大小不合适,所以需要在添加图片前 先修改图片
- //拉伸图片
- UIImage * image = [UIImage imageNamed:@"bubble"];
- //计算左边端盖
- NSInteger leftCap = image.size.width * 0.5f;
- //计算顶部端盖
- NSInteger topCap = image.size.height * 0.5f;
-
- //拉伸imageView的大小 需要传入两个值 左端盖 和上端盖
- image = [image stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
-
- //气泡背景
- _backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(65, 45, kSize.width - 100, 50)];
- [_backImageView setImage:image];
- [self addSubview:_backImageView];
-
- //文本消息
-
- _messageContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(85, 50, kSize.width - 125, 40)];
- [_messageContentLabel setNumberOfLines:0];
- [_messageContentLabel setFont:[UIFont scaleSize:17]];
- [self addSubview:_messageContentLabel];
- }
- return self;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|