礼物飘屏完成
This commit is contained in:
22
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/Contents.json
vendored
Normal file
22
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
BIN
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/room_gift_display_bg@2x.png
vendored
Normal file
BIN
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/room_gift_display_bg@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
BIN
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/room_gift_display_bg@3x.png
vendored
Normal file
BIN
QXLive/Other/Assets.xcassets/room/room_gift_display_bg.imageset/room_gift_display_bg@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
@@ -54,8 +54,8 @@
|
||||
|
||||
CGFloat viewHeight = 40;
|
||||
CGFloat spacing = 10;
|
||||
CGFloat topMargin = 100;
|
||||
CGFloat width = 270;
|
||||
CGFloat topMargin = 400;
|
||||
CGFloat width = 290;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
CGFloat y = topMargin + (viewHeight + spacing) * i;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import "QXGiftDisplayView.h"
|
||||
|
||||
@interface QXGiftDisplayView ()
|
||||
@property (nonatomic, strong) UIImageView *bgImageView;
|
||||
@property (nonatomic, strong) UIImageView *avatarImageView;
|
||||
@property (nonatomic, strong) UILabel *senderLabel;
|
||||
@property (nonatomic, strong) UILabel *giftLabel;
|
||||
@@ -29,12 +30,14 @@
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
|
||||
self.layer.cornerRadius = 20;
|
||||
self.layer.masksToBounds = YES;
|
||||
|
||||
// self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
|
||||
// self.layer.cornerRadius = 20;
|
||||
// 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.masksToBounds = YES;
|
||||
self.avatarImageView.backgroundColor = [UIColor lightGrayColor];
|
||||
@@ -42,36 +45,44 @@
|
||||
[self addSubview:self.avatarImageView];
|
||||
|
||||
// 发送者名称
|
||||
self.senderLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 5, 120, 15)];
|
||||
self.senderLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
self.senderLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.avatarImageView.right+4, 4, 120, 16)];
|
||||
self.senderLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
self.senderLabel.textColor = [UIColor whiteColor];
|
||||
[self addSubview:self.senderLabel];
|
||||
|
||||
// 礼物信息
|
||||
self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 120, 15)];
|
||||
self.giftLabel.font = [UIFont systemFontOfSize:11];
|
||||
self.giftLabel.textColor = [UIColor yellowColor];
|
||||
self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.senderLabel.left, self.bgImageView.height-4-14, 120, 14)];
|
||||
self.giftLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.giftLabel.textColor = RGB16(0xffffff);
|
||||
[self addSubview:self.giftLabel];
|
||||
|
||||
// 礼物图片
|
||||
self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(165, 5, 30, 30)];
|
||||
// self.giftImageView.backgroundColor = [UIColor orangeColor];
|
||||
self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bgImageView.width-self.bgImageView.height, 0, self.bgImageView.height, self.bgImageView.height)];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
self.giftImageView.layer.cornerRadius = 5;
|
||||
self.giftImageView.layer.masksToBounds = YES;
|
||||
[self addSubview:self.giftImageView];
|
||||
|
||||
// 礼物数量
|
||||
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(200, 5, 60, 30)];
|
||||
self.countLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.countLabel.textColor = [UIColor redColor];
|
||||
self.countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bgImageView.right+8, 5, 100, 35)];
|
||||
self.countLabel.font = [UIFont fontWithName:@"DIN Condensed" size:35];
|
||||
self.countLabel.textColor = RGB16(0xFFF49F);
|
||||
self.countLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self addSubview:self.countLabel];
|
||||
|
||||
// 初始位置在屏幕左侧外面
|
||||
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 方法
|
||||
- (void)updateUIWithGift:(QXRoomChatListModel *)gift {
|
||||
if (!gift) return;
|
||||
|
||||
Reference in New Issue
Block a user