换肤完成
@@ -398,10 +398,11 @@
|
||||
}
|
||||
|
||||
-(void)setBtnTypeWithIsFollow:(BOOL)isFollow{
|
||||
[self.focusBtn setTitle:isFollow?QXText(@"跟随"):QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
[self.focusBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
|
||||
self.focusBtn.backgroundColor = RGB16(0x333333);
|
||||
self.focusBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
// [self.focusBtn setTitle:isFollow?QXText(@"跟随"):QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
[self.focusBtn setBackgroundImage:[UIImage imageNamed:isFollow?@"room_user_follow":@"expansion_call"] forState:(UIControlStateNormal)];
|
||||
// [self.focusBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
|
||||
// self.focusBtn.backgroundColor = RGB16(0x333333);
|
||||
// self.focusBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.focusBtn addRoundedCornersWithRadius:12.5];
|
||||
}
|
||||
-(QXSendGiftView *)sendView{
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#import "QXRechargeView.h"
|
||||
#import "QXAppstoreHomeView.h"
|
||||
#import "QXConfig.h"
|
||||
#import "QXSkyPraizeView.h"
|
||||
|
||||
@interface QXHomeViewController ()<JXPagerViewDelegate,JXCategoryViewDelegate,GKCycleScrollViewDataSource,GKCycleScrollViewDelegate,QXGiftScrollViewDelegate,SDCycleScrollViewDelegate>
|
||||
@property (nonatomic, strong) JXPagerView *pagingView;
|
||||
@@ -177,7 +178,9 @@
|
||||
|
||||
|
||||
-(void)firstAction{
|
||||
[self popFirstRechargeView];
|
||||
// [self popFirstRechargeView];
|
||||
QXSkyPraizeView *v = [[QXSkyPraizeView alloc] init];
|
||||
[v showInView:self.view];
|
||||
}
|
||||
-(void)popFirstRechargeView{
|
||||
MJWeakSelf
|
||||
|
||||
@@ -102,17 +102,17 @@ NSInteger maxMessageCount = 20;
|
||||
make.width.mas_equalTo(75);
|
||||
}];
|
||||
|
||||
// self.messageLabel = [[UILabel alloc] init];
|
||||
// self.messageLabel.textColor = [UIColor whiteColor];
|
||||
// self.messageLabel.text = @"张三进入了房间";
|
||||
// self.messageLabel.font = [UIFont systemFontOfSize:12];
|
||||
// [self addSubview:self.messageLabel];
|
||||
// [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(16);
|
||||
// make.bottom.equalTo(self).offset(-5);
|
||||
// make.height.mas_equalTo(20);
|
||||
// make.right.equalTo(self);
|
||||
// }];
|
||||
// self.messageLabel = [[UILabel alloc] init];
|
||||
// self.messageLabel.textColor = [UIColor whiteColor];
|
||||
// self.messageLabel.text = @"张三进入了房间";
|
||||
// self.messageLabel.font = [UIFont systemFontOfSize:12];
|
||||
// [self addSubview:self.messageLabel];
|
||||
// [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(16);
|
||||
// make.bottom.equalTo(self).offset(-5);
|
||||
// make.height.mas_equalTo(20);
|
||||
// make.right.equalTo(self);
|
||||
// }];
|
||||
}
|
||||
-(void)typeAction:(UIButton*)sender{
|
||||
self.selectedBtn.selected = !self.selectedBtn.selected;
|
||||
@@ -202,7 +202,7 @@ NSInteger maxMessageCount = 20;
|
||||
}else{
|
||||
model = self.dataArray[indexPath.row];
|
||||
}
|
||||
// model.havBubble = indexPath.row%2;
|
||||
// model.havBubble = indexPath.row%2;
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
QXRoomChatListCell *cell = [QXRoomChatListCell cellWithTableView:tableView];
|
||||
cell.delegate = self;
|
||||
@@ -244,7 +244,7 @@ NSInteger maxMessageCount = 20;
|
||||
CGFloat height = 0;
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
|
||||
|
||||
if (model.havBubble) {
|
||||
/// 有气泡
|
||||
height = 30+14+6+30 + height;
|
||||
@@ -406,29 +406,29 @@ NSInteger maxMessageCount = 20;
|
||||
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0xffffff, 0.2)];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0x000000, 0.4)];
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0x000000, 0.4);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self.contentView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:self.titleLabel];
|
||||
@@ -462,31 +462,31 @@ NSInteger maxMessageCount = 20;
|
||||
if (!self.message.havBubble) {
|
||||
[self.bubbleImageView sd_cancelLatestImageLoad];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0x000000, 0.4);
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"气泡" ofType:@"webp"];
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL fileURLWithPath:path] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 30, 20 , 30) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
|
||||
|
||||
}];
|
||||
CGFloat height = [self.message.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
self.bubbleImageView.backgroundColor = [UIColor clearColor];
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-48);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
make.height.mas_equalTo(height+60);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self.titleLabel).offset(48);
|
||||
}];
|
||||
@@ -594,29 +594,29 @@ NSInteger maxMessageCount = 20;
|
||||
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0xffffff, 0.2)];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0x000000, 0.4)];
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0x000000, 0.4);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self.contentView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:self.titleLabel];
|
||||
@@ -650,31 +650,31 @@ NSInteger maxMessageCount = 20;
|
||||
if (!self.message.havBubble) {
|
||||
[self.bubbleImageView sd_cancelLatestImageLoad];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0x000000, 0.4);
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"气泡" ofType:@"webp"];
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL fileURLWithPath:path] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 30, 20 , 30) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
|
||||
|
||||
}];
|
||||
CGFloat height = [self.message.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
self.bubbleImageView.backgroundColor = [UIColor clearColor];
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-48);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
make.height.mas_equalTo(height+60);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self.titleLabel).offset(48);
|
||||
}];
|
||||
@@ -719,7 +719,7 @@ NSInteger maxMessageCount = 20;
|
||||
|
||||
-(void)initSubviews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
self.bgView.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
self.bgView.backgroundColor = RGB16A(0x000000, 0.4);
|
||||
[self.bgView addRoundedCornersWithRadius:6];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -730,7 +730,8 @@ NSInteger maxMessageCount = 20;
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.textColor = QXConfig.themeColor;
|
||||
self.titleLabel.textColor = RGB16(0XD1A9FE);
|
||||
// self.titleLabel.textColor = QXConfig.themeColor;
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.titleLabel.numberOfLines = 0;
|
||||
[self.bgView addSubview:self.titleLabel];
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
self.offlineImageView.hidden = YES;
|
||||
}else{
|
||||
self.offlineImageView.hidden = NO;
|
||||
[self stopAudioAnimation];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
return self.headerView;
|
||||
}
|
||||
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
||||
return 215;
|
||||
return 215+26;
|
||||
}
|
||||
|
||||
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||||
@@ -178,7 +178,7 @@
|
||||
}
|
||||
-(QXUserHomeHeaderView *)headerView{
|
||||
if (!_headerView) {
|
||||
_headerView = [[QXUserHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 215)];
|
||||
_headerView = [[QXUserHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 215+26)];
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 打赏价值
|
||||
@property (nonatomic,strong)NSString *total_price;
|
||||
|
||||
/// 公会
|
||||
@property (nonatomic,strong)NSString *guild;
|
||||
|
||||
/// 是否使用靓号 0未使用 1 已使用
|
||||
@property (nonatomic,strong)NSString *is_use_code;
|
||||
@end
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
@property (nonatomic,strong) UILabel * nameLabel;
|
||||
@property (nonatomic,strong) UILabel * idLabel;
|
||||
@property (nonatomic,strong) UILabel * ageLabel;
|
||||
@property (nonatomic,strong) UILabel * guildLabel;
|
||||
@property (nonatomic,strong) UICollectionView * collectionView;
|
||||
@property (nonatomic,strong) NSMutableArray * tagArray;
|
||||
@property (nonatomic,strong) UILabel *introduceLabel;
|
||||
@@ -119,6 +120,18 @@
|
||||
}];
|
||||
|
||||
|
||||
self.guildLabel = [[UILabel alloc] init];
|
||||
self.guildLabel.textColor = RGB16(0x999999);
|
||||
self.guildLabel.text = @"所属公会";
|
||||
self.guildLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
[self addSubview:self.guildLabel];
|
||||
[self.guildLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.height.mas_equalTo(18);
|
||||
make.top.equalTo(self.ageLabel.mas_bottom).offset(8);
|
||||
make.width.mas_greaterThanOrEqualTo(35);
|
||||
}];
|
||||
|
||||
self.introduceLabel = [[UILabel alloc] init];
|
||||
self.introduceLabel.textColor = QXConfig.textColor;
|
||||
self.introduceLabel.font = [UIFont systemFontOfSize:14];
|
||||
@@ -126,7 +139,7 @@
|
||||
[self addSubview:self.introduceLabel];
|
||||
[self.introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.top.equalTo(self.ageLabel.mas_bottom).offset(4);
|
||||
make.top.equalTo(self.guildLabel.mas_bottom).offset(4);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH-64);
|
||||
make.height.mas_greaterThanOrEqualTo(22);
|
||||
}];
|
||||
@@ -266,12 +279,18 @@
|
||||
self.playBtn.hidden = NO;
|
||||
self.followBtn.selected = model.is_follow==0?NO:YES;
|
||||
if (model.room_id.intValue > 0) {
|
||||
[self.playBtn setTitle:QXText(@"跟随") forState:(UIControlStateNormal)];
|
||||
// [self.playBtn setTitle:QXText(@"跟随") forState:(UIControlStateNormal)];
|
||||
[self.playBtn setBackgroundImage:[UIImage imageNamed:@"room_user_follow"] forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
[self.playBtn setTitle:QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
// [self.playBtn setTitle:QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
[self.playBtn setBackgroundImage:[UIImage imageNamed:@"expansion_call"] forState:(UIControlStateNormal)];
|
||||
}
|
||||
}
|
||||
|
||||
if ([model.guild isExist]) {
|
||||
self.guildLabel.text = [NSString stringWithFormat:@"所属公会:%@",model.guild];
|
||||
}else{
|
||||
self.guildLabel.text = [NSString stringWithFormat:@"所属公会:%@",@"无"];
|
||||
}
|
||||
if (model.is_use_code.intValue == 1) {
|
||||
self.useCodeImageView.hidden = NO;
|
||||
}else{
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1381@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1381@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1403@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1403@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1427@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1427@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1428@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 1428@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 8@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 8@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 895@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame 895@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@2x(4).png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@3x(4).png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 643 B |
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@2x(7).png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@3x(7).png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Frame@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 648 B |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 25@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 25@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7053@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7053@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7055@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7055@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7056@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7056@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7072@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7072@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7074@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7074@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7075@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 7075@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
30
QXLive/活动/QXSkyPraizeView.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// QXSkyPraizeView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXSkyPraizeView : UIView
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXSkyPraizeSubView :UIView
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
|
||||
@property (nonatomic,assign)BOOL isSelected;
|
||||
|
||||
- (void)startPulseAnimationWithLayer;
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer;
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
459
QXLive/活动/QXSkyPraizeView.m
Normal file
@@ -0,0 +1,459 @@
|
||||
//
|
||||
// QXSkyPraizeView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import "QXSkyPraizeView.h"
|
||||
/// 共有12个礼物
|
||||
static NSInteger giftMaxCount = 12;
|
||||
/// 最少转2圈
|
||||
static NSInteger minRoundCount = 2;
|
||||
/// 距离4个的时候放慢
|
||||
static NSInteger toSlowCount = 4;
|
||||
|
||||
@interface QXSkyPraizeView()<UIGestureRecognizerDelegate>
|
||||
/// 目标下标
|
||||
@property (nonatomic,assign)NSInteger targetIndex;
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray* targetArrayIndex;
|
||||
@property (nonatomic,strong)NSMutableArray* finishTargetArrayIndex;
|
||||
/// 当前转动到第几个下标
|
||||
@property (nonatomic,assign)NSInteger currentIndex;
|
||||
/// 转动了多少次
|
||||
@property (nonatomic,assign)NSInteger roundCount;
|
||||
/// 延时
|
||||
@property (nonatomic,assign)double delayTime;
|
||||
/// 22 抽一次 33 抽十次 44 抽 100次
|
||||
@property (nonatomic,assign)NSInteger startType;
|
||||
|
||||
@property (nonatomic,strong)QXSkyPraizeSubView *currentGiftView;
|
||||
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)NSMutableArray *allViewsArray;
|
||||
|
||||
@property (nonatomic,strong)dispatch_source_t fastTimer;
|
||||
@property (nonatomic,strong)dispatch_source_t slowTimer;
|
||||
@end
|
||||
|
||||
@implementation QXSkyPraizeView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
||||
tap.delegate = self;
|
||||
[self addGestureRecognizer:tap];
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||||
|
||||
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(520)+kSafeAreaBottom)];
|
||||
self.bgView.backgroundColor = UIColor.whiteColor;
|
||||
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[self addSubview:self.bgView];
|
||||
|
||||
|
||||
CGFloat topMargin = 60;
|
||||
CGFloat margin = 16;
|
||||
CGFloat space = 10;
|
||||
CGFloat itemWidth = (SCREEN_WIDTH - margin*2 - space*3) / 4;
|
||||
CGFloat itemHeight = itemWidth/7*8;;
|
||||
for (int i = 0; i < giftMaxCount; i++) {
|
||||
QXSkyPraizeSubView *giftView;
|
||||
if (i < 4) {
|
||||
/// 第一行4个
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*i, topMargin, itemWidth, itemHeight)];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",i];
|
||||
[self.allViewsArray replaceObjectAtIndex:i withObject:giftView];
|
||||
}else if (i > 3 && i < 6){
|
||||
/// 第二行两个
|
||||
if (i == 4) {
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",11];
|
||||
[self.allViewsArray replaceObjectAtIndex:11 withObject:giftView];
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*3, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:4 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",4];
|
||||
}
|
||||
}else if (i > 5 && i < 8){
|
||||
/// 第三行两个
|
||||
if (i == 6) {
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:10 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",10];
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*3, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:5 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",5];
|
||||
}
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*(i%4), topMargin+(itemHeight+space)*3, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:11-(i-6) withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",11-(i-6)];
|
||||
}
|
||||
|
||||
[self.bgView addSubview:giftView];
|
||||
}
|
||||
[self resetViews];
|
||||
|
||||
|
||||
|
||||
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(16, 20, 100, 40)];
|
||||
[btn setTitle:@"抽1次" forState:(UIControlStateNormal)];
|
||||
[btn setTitleColor:UIColor.blueColor forState:(UIControlStateNormal)];
|
||||
btn.tag = 22;
|
||||
[btn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:btn];
|
||||
|
||||
UIButton *tenBtn = [[UIButton alloc] initWithFrame:CGRectMake(116, 20, 100, 40)];
|
||||
[tenBtn setTitle:@"抽10次" forState:(UIControlStateNormal)];
|
||||
tenBtn.tag = 33;
|
||||
[tenBtn setTitleColor:UIColor.blueColor forState:(UIControlStateNormal)];
|
||||
[tenBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:tenBtn];
|
||||
|
||||
|
||||
UIButton *hundredBtn = [[UIButton alloc] initWithFrame:CGRectMake(216, 20, 100, 40)];
|
||||
[hundredBtn setTitle:@"抽100次" forState:(UIControlStateNormal)];
|
||||
hundredBtn.tag = 44;
|
||||
[hundredBtn setTitleColor:UIColor.blueColor forState:(UIControlStateNormal)];
|
||||
[hundredBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:hundredBtn];
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
-(void)startAction:(UIButton*)sender{
|
||||
|
||||
self.startType = sender.tag;
|
||||
/// 获取目标礼物
|
||||
[self resetViews];
|
||||
[self getTargetGift];
|
||||
[self startFastAnimate];
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)resetViews{
|
||||
self.targetIndex = -1;
|
||||
self.currentIndex = -1;
|
||||
self.roundCount = 0;
|
||||
self.delayTime = 0.3;
|
||||
[self.targetArrayIndex removeAllObjects];
|
||||
[self.finishTargetArrayIndex removeAllObjects];
|
||||
if (self.currentGiftView != nil) {
|
||||
self.currentGiftView.isSelected = NO;
|
||||
[self.currentGiftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
for (QXSkyPraizeSubView *giftView in self.allViewsArray) {
|
||||
giftView.isSelected = NO;
|
||||
[giftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)startFastAnimate{
|
||||
self.currentGiftView = self.allViewsArray.firstObject;
|
||||
self.currentGiftView.isSelected = YES;
|
||||
[self stopFastAnimate];
|
||||
if (_fastTimer == nil) {
|
||||
_fastTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
|
||||
}
|
||||
// dispatch_source_set_timer(_fastTimer,
|
||||
// dispatch_time(DISPATCH_TIME_NOW, 0),
|
||||
// NSEC_PER_SEC * 0.06, // 间隔0.1秒
|
||||
// NSEC_PER_SEC * 0.01); // 允许误差0.01秒
|
||||
|
||||
dispatch_source_set_timer(_fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.06 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER, // 使用一次性模式
|
||||
0.01 * NSEC_PER_SEC);
|
||||
__weak typeof(self) weakSelf = self;
|
||||
dispatch_source_set_event_handler(_fastTimer, ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) return;
|
||||
// 如果需要更新UI,切换到主线程
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
strongSelf.roundCount++;
|
||||
|
||||
if ((strongSelf.roundCount / giftMaxCount == minRoundCount) && strongSelf.startType != 22) {
|
||||
BOOL has = NO;
|
||||
for (NSNumber *index in self.finishTargetArrayIndex) {
|
||||
if (index.integerValue == self.currentIndex) {
|
||||
has = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.currentGiftView.isSelected = NO;
|
||||
if (has) {
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
}else{
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = NO;
|
||||
}
|
||||
}else{
|
||||
/// 把上一个选中状态置为未选中
|
||||
strongSelf.currentGiftView.isSelected = NO;
|
||||
}
|
||||
/// 计算当前下标
|
||||
strongSelf.currentIndex = strongSelf.roundCount%giftMaxCount;
|
||||
/// 获取当前选中的view 并设置为选中状态
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
|
||||
/// 重新赋值给选中view
|
||||
strongSelf.currentGiftView = giftView;
|
||||
|
||||
if (strongSelf.roundCount / giftMaxCount == minRoundCount) {
|
||||
|
||||
/// 已经转了2圈
|
||||
if (strongSelf.startType == 22) {
|
||||
|
||||
NSInteger index = strongSelf.targetIndex;
|
||||
// 0 - > 11
|
||||
// 1 - > 12
|
||||
// 2->13
|
||||
// 3->14
|
||||
// 4->15
|
||||
// 处理0-4数据无法匹配问题
|
||||
if (index < 5) {
|
||||
index = (giftMaxCount-1) + index;
|
||||
}
|
||||
if ((strongSelf.currentIndex + toSlowCount) == index) {
|
||||
//距离目标差4
|
||||
QXLOG(@"当前下标为%ld---目标为%ld",strongSelf.currentIndex,strongSelf.targetIndex);
|
||||
[self stopFastAnimate];
|
||||
[self startSlowAnimate];
|
||||
}else{
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.06 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}
|
||||
|
||||
}else{
|
||||
// for (QXSkyPraizeSubView *giftView in strongSelf.allViewsArray) {
|
||||
// giftView.isSelected = NO;
|
||||
// }
|
||||
BOOL has = NO;
|
||||
for (NSNumber *index in strongSelf.targetArrayIndex) {
|
||||
if (strongSelf.currentIndex == index.integerValue) {
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[index.integerValue];
|
||||
giftView.isSelected = YES;
|
||||
[giftView startPulseAnimationWithLayer];
|
||||
// [strongSelf pauseGCDTimer];
|
||||
[strongSelf.targetArrayIndex removeObject:index];
|
||||
[strongSelf.finishTargetArrayIndex addObject:index];
|
||||
has = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// [strongSelf resumeGCDTimer];
|
||||
// });
|
||||
if (has) {
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}else{
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.06 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}
|
||||
if (strongSelf.targetArrayIndex.count == 0) {
|
||||
[strongSelf stopFastAnimate];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.06 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
dispatch_resume(_fastTimer);
|
||||
}
|
||||
|
||||
-(void)startSlowAnimate{
|
||||
|
||||
if (_slowTimer == nil) {
|
||||
_slowTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
|
||||
}
|
||||
// 立即开始,初始间隔0.1秒
|
||||
dispatch_source_set_timer(_slowTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, self.delayTime * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER, // 使用一次性模式
|
||||
0.01 * NSEC_PER_SEC);
|
||||
__weak typeof(self) weakSelf = self;
|
||||
dispatch_source_set_event_handler(_slowTimer, ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) return;
|
||||
// 如果需要更新UI,切换到主线程
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
/// 把上一个选中状态置为未选中
|
||||
strongSelf.currentGiftView.isSelected = NO;
|
||||
|
||||
strongSelf.roundCount++;
|
||||
/// 计算当前下标
|
||||
strongSelf.currentIndex = strongSelf.roundCount%giftMaxCount;
|
||||
/// 获取当前选中的view 并设置为选中状态
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
|
||||
/// 重新赋值给选中view
|
||||
strongSelf.currentGiftView = giftView;
|
||||
|
||||
if (strongSelf.currentIndex == strongSelf.targetIndex) {
|
||||
//距离目标差4
|
||||
QXLOG(@"礼物结束====当前下标为%ld---目标为%ld",strongSelf.currentIndex,strongSelf.targetIndex);
|
||||
[strongSelf stopSlowAnimate];
|
||||
[strongSelf.currentGiftView startPulseAnimationWithLayer];
|
||||
}
|
||||
});
|
||||
strongSelf.delayTime = strongSelf.delayTime+0.1;
|
||||
dispatch_source_set_timer(strongSelf.slowTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, strongSelf.delayTime * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
});
|
||||
dispatch_resume(_slowTimer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)stopFastAnimate{
|
||||
if (_fastTimer != nil) {
|
||||
dispatch_source_cancel(_fastTimer);
|
||||
_fastTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pauseGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_suspend(_fastTimer);
|
||||
NSLog(@"GCD定时器已暂停");
|
||||
}
|
||||
}
|
||||
- (void)resumeGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_resume(_fastTimer);
|
||||
NSLog(@"GCD定时器已恢复");
|
||||
}
|
||||
}
|
||||
|
||||
-(void)stopSlowAnimate{
|
||||
if (_slowTimer != nil) {
|
||||
dispatch_source_cancel(_slowTimer);
|
||||
_slowTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)getTargetGift{
|
||||
self.targetArrayIndex = [NSMutableArray arrayWithArray:@[@3,@5,@8,@10]];
|
||||
if (self.startType == 22) {
|
||||
self.targetIndex = arc4random() % 12;
|
||||
}else{
|
||||
// NSNumber *number = self.targetArrayIndex.firstObject;
|
||||
// self.targetIndex = number.integerValue;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)getTenTargetGift{
|
||||
|
||||
}
|
||||
|
||||
-(NSMutableArray *)allViewsArray{
|
||||
if (!_allViewsArray) {
|
||||
_allViewsArray = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@""]];
|
||||
}
|
||||
return _allViewsArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-(NSMutableArray *)finishTargetArrayIndex{
|
||||
if (!_finishTargetArrayIndex) {
|
||||
_finishTargetArrayIndex = [NSMutableArray array];
|
||||
}
|
||||
return _finishTargetArrayIndex;
|
||||
}
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(520)-kSafeAreaBottom;
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
[self stopFastAnimate];
|
||||
[self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyPraizeSubView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = [UIColor cyanColor];
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:22];
|
||||
self.titleLabel.textColor = UIColor.blackColor;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
}
|
||||
-(void)setIsSelected:(BOOL)isSelected{
|
||||
_isSelected = isSelected;
|
||||
self.backgroundColor = isSelected?[UIColor blueColor]:[UIColor cyanColor];
|
||||
}
|
||||
- (void)startPulseAnimationWithLayer {
|
||||
CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
|
||||
pulseAnimation.duration = 0.5;
|
||||
pulseAnimation.fromValue = @0.9;
|
||||
pulseAnimation.toValue = @1.1;
|
||||
pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
pulseAnimation.autoreverses = YES;
|
||||
pulseAnimation.repeatCount = HUGE_VALF; // 无限循环
|
||||
|
||||
[self.layer addAnimation:pulseAnimation forKey:@"pulse"];
|
||||
|
||||
}
|
||||
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer {
|
||||
[self.layer removeAnimationForKey:@"pulse"];
|
||||
}
|
||||
@end
|
||||