完成
This commit is contained in:
179
QXLive/活动/巡乐会/QXMeetActivityResultView.m
Normal file
179
QXLive/活动/巡乐会/QXMeetActivityResultView.m
Normal file
@@ -0,0 +1,179 @@
|
||||
//
|
||||
// QXMeetActivityResultView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/30.
|
||||
//
|
||||
|
||||
#import "QXMeetActivityResultView.h"
|
||||
@interface QXMeetActivityResultView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
|
||||
@property (nonatomic,strong)UIButton *againBtn;
|
||||
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@end
|
||||
@implementation QXMeetActivityResultView
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||||
self.bgView = [[UIView alloc] init];
|
||||
[self addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(430);
|
||||
make.centerY.equalTo(self);
|
||||
}];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_draw_result_bg"]];
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(331);
|
||||
make.height.mas_equalTo(364);
|
||||
make.top.equalTo(self.bgView);
|
||||
make.centerX.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.bgImageView);
|
||||
make.top.mas_equalTo(115);
|
||||
make.bottom.equalTo(self.bgImageView);
|
||||
}];
|
||||
|
||||
self.againBtn = [[UIButton alloc] init];
|
||||
[self.againBtn setBackgroundImage:[UIImage imageNamed:@"ac_meet_again_btn"] forState:(UIControlStateNormal)];
|
||||
[self.againBtn addTarget:self action:@selector(againAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:self.againBtn];
|
||||
[self.againBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgView);
|
||||
make.width.mas_equalTo(140);
|
||||
make.height.mas_equalTo(46);
|
||||
make.centerX.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setImage:[UIImage imageNamed:@"ac_meet_result_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.top.equalTo(self.bgView);
|
||||
make.height.mas_equalTo(40);
|
||||
make.width.mas_equalTo(40);
|
||||
}];
|
||||
}
|
||||
-(void)setTimes:(NSString *)times{
|
||||
_times = times;
|
||||
}
|
||||
-(void)setResultArray:(NSArray *)resultArray{
|
||||
_resultArray = resultArray;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.resultArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXMeetActivityResultCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXMeetActivityResultCell" forIndexPath:indexPath];
|
||||
cell.model = self.resultArray[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 20;
|
||||
layout.minimumInteritemSpacing = 20;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12);
|
||||
layout.itemSize = CGSizeMake((331-12*2-20*2)/3,100);
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.showsVerticalScrollIndicator = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[QXMeetActivityResultCell class] forCellWithReuseIdentifier:@"QXMeetActivityResultCell"];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
-(void)againAction{
|
||||
[self hide];
|
||||
if (self.againBlock) {
|
||||
self.againBlock(self.times);
|
||||
}
|
||||
}
|
||||
-(void)closeAction{
|
||||
[self hide];
|
||||
}
|
||||
-(void)showInView:(UIView *)view{
|
||||
// self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
// [UIView animateWithDuration:0.3 animations:^{
|
||||
// self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
// }];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
// [UIView animateWithDuration:0.3 animations:^{
|
||||
// self.bgView.y = SCREEN_HEIGHT;
|
||||
// } completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
// }];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXMeetActivityResultCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXDrawGiftModel *)model{
|
||||
_model = model;
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.giftNameLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.giftBgImageView = [[UIImageView alloc] init];
|
||||
[self.contentView addSubview:self.giftBgImageView];
|
||||
[self.giftBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.equalTo(self.contentView);
|
||||
make.height.equalTo(self.giftBgImageView.mas_width);
|
||||
}];
|
||||
self.giftImageView =[[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.giftBgImageView);
|
||||
}];
|
||||
|
||||
self.giftNameLabel = [[UILabel alloc] init];
|
||||
self.giftNameLabel.textColor = RGB16(0xffffff);
|
||||
self.giftNameLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.giftNameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.giftNameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
|
||||
[self.contentView addSubview:self.giftNameLabel];
|
||||
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.right.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user