SellyCloudSDK_demo/Example/SellyCloudSDK/Play/SCPlayItemContainerView.m

58 lines
1.4 KiB
Objective-C

//
// SCLiveItemContainerView.m
// SellyCloudSDK_Example
//
// Created by Caleb on 21/7/25.
// Copyright © 2025 Caleb. All rights reserved.
//
#import "SCPlayItemContainerView.h"
#import "SCPlayItemView.h"
@interface SCPlayItemContainerView ()
@property (nonatomic, strong)NSMutableArray<SCPlayItemView *> *itemViews;
@end
@implementation SCPlayItemContainerView
- (instancetype)init
{
self = [super init];
if (self) {
self.backgroundColor = UIColor.cyanColor;
}
return self;
}
- (void)setModels:(NSArray<SCPlayItemModel *> *)models {
_models = models;
[self.itemViews enumerateObjectsUsingBlock:^(SCPlayItemView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj removeFromSuperview];
}];
[self.itemViews removeAllObjects];
for (NSInteger i = 0; i<models.count; i++) {
SCPlayItemView *itemView = SCPlayItemView.new;
itemView.model = models[i];
[self.itemViews addObject:itemView];
[self addSubview:itemView];
}
[self.itemViews mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:100 leadSpacing:15 tailSpacing:15];
[self.itemViews mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.offset(80);
make.centerY.offset(0);
}];
}
- (NSMutableArray<SCPlayItemView *> *)itemViews {
if (!_itemViews) {
_itemViews = NSMutableArray.array;
}
return _itemViews;
}
@end