礼物飘屏完成

This commit is contained in:
启星
2025-10-21 11:36:48 +08:00
parent c0502d1f7b
commit ca98dff004
5 changed files with 53 additions and 20 deletions

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_display_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_display_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View File

@@ -54,8 +54,8 @@
CGFloat viewHeight = 40; CGFloat viewHeight = 40;
CGFloat spacing = 10; CGFloat spacing = 10;
CGFloat topMargin = 100; CGFloat topMargin = 400;
CGFloat width = 270; CGFloat width = 290;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
CGFloat y = topMargin + (viewHeight + spacing) * i; CGFloat y = topMargin + (viewHeight + spacing) * i;

View File

@@ -9,6 +9,7 @@
#import "QXGiftDisplayView.h" #import "QXGiftDisplayView.h"
@interface QXGiftDisplayView () @interface QXGiftDisplayView ()
@property (nonatomic, strong) UIImageView *bgImageView;
@property (nonatomic, strong) UIImageView *avatarImageView; @property (nonatomic, strong) UIImageView *avatarImageView;
@property (nonatomic, strong) UILabel *senderLabel; @property (nonatomic, strong) UILabel *senderLabel;
@property (nonatomic, strong) UILabel *giftLabel; @property (nonatomic, strong) UILabel *giftLabel;
@@ -29,12 +30,14 @@
} }
- (void)setupUI { - (void)setupUI {
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7]; // self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
self.layer.cornerRadius = 20; // self.layer.cornerRadius = 20;
self.layer.masksToBounds = YES; // self.layer.masksToBounds = YES;
self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 223, 40)];
self.bgImageView.image = [UIImage imageNamed:@"room_gift_display_bg"];
[self addSubview:self.bgImageView];
// //
self.avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 30, 30)]; self.avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(4, 4, 32, 32)];
self.avatarImageView.layer.cornerRadius = 15; self.avatarImageView.layer.cornerRadius = 15;
self.avatarImageView.layer.masksToBounds = YES; self.avatarImageView.layer.masksToBounds = YES;
self.avatarImageView.backgroundColor = [UIColor lightGrayColor]; self.avatarImageView.backgroundColor = [UIColor lightGrayColor];
@@ -42,36 +45,44 @@
[self addSubview:self.avatarImageView]; [self addSubview:self.avatarImageView];
// //
self.senderLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 5, 120, 15)]; self.senderLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.avatarImageView.right+4, 4, 120, 16)];
self.senderLabel.font = [UIFont boldSystemFontOfSize:12]; self.senderLabel.font = [UIFont boldSystemFontOfSize:14];
self.senderLabel.textColor = [UIColor whiteColor]; self.senderLabel.textColor = [UIColor whiteColor];
[self addSubview:self.senderLabel]; [self addSubview:self.senderLabel];
// //
self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 120, 15)]; self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.senderLabel.left, self.bgImageView.height-4-14, 120, 14)];
self.giftLabel.font = [UIFont systemFontOfSize:11]; self.giftLabel.font = [UIFont systemFontOfSize:12];
self.giftLabel.textColor = [UIColor yellowColor]; self.giftLabel.textColor = RGB16(0xffffff);
[self addSubview:self.giftLabel]; [self addSubview:self.giftLabel];
// //
self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(165, 5, 30, 30)]; self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bgImageView.width-self.bgImageView.height, 0, self.bgImageView.height, self.bgImageView.height)];
// self.giftImageView.backgroundColor = [UIColor orangeColor];
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit; self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
self.giftImageView.layer.cornerRadius = 5;
self.giftImageView.layer.masksToBounds = YES;
[self addSubview:self.giftImageView]; [self addSubview:self.giftImageView];
// //
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(200, 5, 60, 30)]; self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bgImageView.right+8, 5, 100, 35)];
self.countLabel.font = [UIFont boldSystemFontOfSize:16]; self.countLabel.font = [UIFont fontWithName:@"DIN Condensed" size:35];
self.countLabel.textColor = [UIColor redColor]; self.countLabel.textColor = RGB16(0xFFF49F);
self.countLabel.textAlignment = NSTextAlignmentCenter; self.countLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:self.countLabel]; [self addSubview:self.countLabel];
// //
self.frame = CGRectMake(-self.bounds.size.width, self.frame.origin.y, self.bounds.size.width, self.bounds.size.height); self.frame = CGRectMake(-self.bounds.size.width, self.frame.origin.y, self.bounds.size.width, self.bounds.size.height);
} }
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *hitView= [super hitTest:point withEvent:event];
if (hitView== self)
{
return nil;
}
else
{
return hitView;
}
}
// updateUIWithGift // updateUIWithGift
- (void)updateUIWithGift:(QXRoomChatListModel *)gift { - (void)updateUIWithGift:(QXRoomChatListModel *)gift {
if (!gift) return; if (!gift) return;