73 lines
2.1 KiB
Objective-C
73 lines
2.1 KiB
Objective-C
//
|
|
// MapMessageCustomCell.m
|
|
// EscortProject
|
|
//
|
|
// Created by 仁康信息 on 2023/7/7.
|
|
//
|
|
|
|
#import "MapMessageCustomCell.h"
|
|
|
|
@implementation MapMessageCustomCell
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
// Initialization code
|
|
}
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
[super setSelected:selected animated:animated];
|
|
|
|
// Configure the view for the selected state
|
|
}
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
|
{
|
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
if (self) {
|
|
self.container.layer.cornerRadius = 8;
|
|
self.container.layer.masksToBounds = YES;
|
|
self.container.backgroundColor = UIColor.whiteColor;
|
|
|
|
self.myTextLabel = [[UILabel alloc] init];
|
|
self.myTextLabel.textAlignment = NSTextAlignmentLeft;
|
|
self.myTextLabel.font = [UIFont systemFontOfSize:14];
|
|
self.myTextLabel.numberOfLines = 0;
|
|
[self.container addSubview:self.myTextLabel];
|
|
|
|
self.mapImage = [[UIImageView alloc] init];
|
|
[self.container addSubview:self.mapImage];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)fillWithData:(MapMessageCustomCellData *)data;
|
|
{
|
|
[super fillWithData:data];
|
|
self.bubbleView.image = nil;
|
|
self.myTextLabel.text = data.text.length > 0 ? data.text : @"我的位置";
|
|
[self.mapImage sd_setImageWithURL:[NSURL URLWithString:data.MapPictureImg] placeholderImage:nil];
|
|
[self setNeedsLayout];
|
|
}
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
|
|
CGFloat containerW = self.container.bounds.size.width;
|
|
CGFloat containerH = self.container.bounds.size.height;
|
|
CGFloat padding = 10;
|
|
CGFloat textWidth = containerW - padding * 2;
|
|
CGSize textSize = [self.myTextLabel sizeThatFits:CGSizeMake(textWidth, CGFLOAT_MAX)];
|
|
CGFloat textHeight = textSize.height + 12;
|
|
|
|
self.myTextLabel.mm_left(padding).mm_top(6).mm_width(textWidth).mm_height(textHeight);
|
|
|
|
CGFloat mapTop = self.myTextLabel.mm_y + textHeight;
|
|
self.mapImage.mm_left(0).mm_top(mapTop).mm_width(containerW).mm_height(containerH - mapTop);
|
|
|
|
}
|
|
@end
|
|
|
|
|