cdts/xdts-ios 3/TreeHole/Code/Features/VIP/VIPSpecialInfoCell.m

80 lines
2.3 KiB
Mathematica
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
//
// VIPSpecialInfoCell.m
// TreeHole
//
// Created by on 2022/5/1.
//
#import "VIPSpecialInfoCell.h"
CGFloat SpecialInfoCellAspectRatio = 348 / 375.0;
NSString * VIPSpecialInfoCellReuseID = @"VIPSpecialInfoCellReuseID = @"";";
@interface VIPSpecialInfoCell()
@property (nonatomic, strong) PYImageView *coverImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@end
@implementation VIPSpecialInfoCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
self.width = SCREEN_WIDTH;
self.height = SpecialInfoCellAspectRatio * self.width;
PYImageView *coverImageView = [[PYImageView alloc] init];
coverImageView.width = SCREEN_WIDTH;
coverImageView.height = SCREEN_WIDTH * 220.0 / 375.0;
[self.contentView addSubview:coverImageView];
self.coverImageView = coverImageView;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.textColor = UIColor.whiteColor;
titleLabel.font = MT_FONT_MEDIUM_SIZE(22);
titleLabel.height = FIX_SIZE(35);
titleLabel.y = coverImageView.bottom + FIX_SIZE(10);
titleLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:titleLabel];
self.titleLabel = titleLabel;
UILabel *contentLabel = [[UILabel alloc] init];
contentLabel.textColor = COLOR_WITH_RGB(0xB3B3B3);
contentLabel.font = MT_FONT_REGULAR_SIZE(15);
contentLabel.height = FIX_SIZE(25);
contentLabel.y = titleLabel.bottom + FIX_SIZE(8);
contentLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:contentLabel];
self.contentLabel = contentLabel;
}
- (void)setItem:(VIPItem *)item {
_item = item;
self.coverImageView.imageUrl = item.img;
self.titleLabel.text = item.title;
self.contentLabel.text = item.des;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.coverImageView.width = self.width;
self.coverImageView.height = self.width * 220.0 / 375.0;
self.contentLabel.width = self.width;
self.titleLabel.width = self.width;
self.titleLabel.y = self.coverImageView.bottom + FIX_SIZE(10);
self.contentLabel.y = self.titleLabel.bottom + FIX_SIZE(8);
}
@end