Files
mier_ios/SweetParty/主类/RCMic/Room/GiftView/BJGiftBlindItemCell.m
2025-08-11 10:43:19 +08:00

84 lines
2.4 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// BJGiftBlindItemCell.m
// SweetParty
//
// Created by yons on 2024/11/21.
//
#import "BJGiftBlindItemCell.h"
@interface BJGiftBlindItemCell ()
{
CAKeyframeAnimation* animation;
}
@end
@implementation BJGiftBlindItemCell
static NSString *ReuseIdentifier = @"BJGiftBlindItemCell";
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
#pragma mark - 快速创建cell
+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath{
BJGiftBlindItemCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:ReuseIdentifier forIndexPath:indexPath];
return cell;
}
- (void)setModel:(BJRoomGiftModel *)model {
_model = model;
[self.giftImgV sd_setImageWithURL:[NSURL URLWithString:model.base_image] placeholderImage:ImageNamed(@"未加载图片")];
self.priceL.text = C_string(model.gift_price);
self.giftName.text = C_string(model.gift_name);
if (model.isItemSelected) {
[self changeUISelected:YES];
}else {
[self changeUISelected:NO];
}
}
- (void)changeUISelected:(BOOL)isSelected {
if (isSelected) {
[self shakeToShow:self.giftImgV];
self.bgImgV.image = ImageNamed(@"room_alert_apply_gift_sel");
self.giftName.textColor = kBlackColor;
self.priceL.textColor = kBlackColor;
}else {
[self.giftImgV.layer removeAllAnimations];
self.bgImgV.image = ImageNamed(@"room_alert_apply_gift_nor");
self.giftName.textColor = kWhiteColor;
self.priceL.textColor = kWhiteColor;
}
}
/** 设置缩放动画 */
- (void) shakeToShow:(UIView*)aView
{
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 1.5;// 动画时间
animation.repeatCount = 100000;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)]];
// 这三个数字我只研究了前两个所以最后一个数字我还是按照它原来写1.0前两个是控制view的大小的
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)]];
animation.values = values;
[aView.layer addAnimation:animation forKey:@"iconAnimation"];
}
@end