84 lines
2.4 KiB
Objective-C
84 lines
2.4 KiB
Objective-C
//
|
||
// 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
|