我的
This commit is contained in:
27
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.h
Normal file
27
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// QXMineGiftWallCell.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/11/5.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXMineGiftWallCell : UICollectionViewCell
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *giftImageView;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImageView1;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImageView2;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImageView3;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *userCountLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *giftCoinBtn;
|
||||
|
||||
@property (nonatomic,assign)BOOL isLight;
|
||||
@property (nonatomic,strong)QXUserGiftWallModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
106
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.m
Normal file
106
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.m
Normal file
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// QXMineGiftWallCell.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/11/5.
|
||||
//
|
||||
|
||||
#import "QXMineGiftWallCell.h"
|
||||
#import <CoreImage/CoreImage.h>
|
||||
@implementation QXMineGiftWallCell
|
||||
-(void)setIsLight:(BOOL)isLight{
|
||||
_isLight = isLight;
|
||||
self.bgImageView.image = [UIImage imageNamed:isLight?@"user_giftwall_light":@"user_giftwall_gray"];
|
||||
// if (isLight) {
|
||||
// self.userCountLabel.hidden = NO;
|
||||
// }else{
|
||||
// self.userCountLabel.hidden = YES;
|
||||
// self.userImageView1.hidden = YES;
|
||||
// self.userImageView2.hidden = YES;
|
||||
// self.userImageView3.hidden = YES;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
- (UIImage *)convertImageToGrayWithCoreImage:(UIImage *)inputImage {
|
||||
CIImage *ciImage = [[CIImage alloc] initWithImage:inputImage];
|
||||
|
||||
// 使用黑白滤镜
|
||||
CIFilter *grayFilter = [CIFilter filterWithName:@"CIColorControls"];
|
||||
[grayFilter setValue:ciImage forKey:kCIInputImageKey];
|
||||
[grayFilter setValue:@(0.0) forKey:kCIInputSaturationKey]; // 饱和度设为0即为灰色
|
||||
|
||||
CIImage *outputImage = [grayFilter valueForKey:kCIOutputImageKey];
|
||||
|
||||
CIContext *context = [CIContext contextWithOptions:nil];
|
||||
CGImageRef cgImage = [context createCGImage:outputImage fromRect:[outputImage extent]];
|
||||
|
||||
UIImage *grayImage = [UIImage imageWithCGImage:cgImage];
|
||||
CGImageRelease(cgImage);
|
||||
|
||||
return grayImage;
|
||||
}
|
||||
|
||||
-(void)setModel:(QXUserGiftWallModel *)model{
|
||||
_model = model;
|
||||
self.countLabel.text = [NSString stringWithFormat:@"共计%@个",model.total_count];
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image] placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
if (!self.isLight) {
|
||||
image = [self convertImageToGrayWithCoreImage:image];
|
||||
}
|
||||
self.giftImageView.image = image;
|
||||
}];
|
||||
self.nameLabel.text = model.gift_name;
|
||||
[self.giftCoinBtn setTitle:[NSString stringWithFormat:@" %@",model.gift_price] forState:(UIControlStateNormal)];
|
||||
self.userCountLabel.text = [NSString stringWithFormat:@"等%@人",model.top_users_count];
|
||||
|
||||
if (model.top_users.count > 0) {
|
||||
self.countLabel.hidden = NO;
|
||||
self.userCountLabel.hidden = NO;
|
||||
QXUserHomeModel *md1;
|
||||
QXUserHomeModel *md2;
|
||||
QXUserHomeModel *md3;
|
||||
if (model.top_users.count >= 3){
|
||||
self.userImageView1.hidden = NO;
|
||||
self.userImageView2.hidden = NO;
|
||||
self.userImageView3.hidden = NO;
|
||||
md1 = model.top_users[0];
|
||||
md2 = model.top_users[1];
|
||||
md3 = model.top_users[2];
|
||||
[self.userImageView1 sd_setImageWithURL:[NSURL URLWithString:md1.avatar]];
|
||||
[self.userImageView2 sd_setImageWithURL:[NSURL URLWithString:md2.avatar]];
|
||||
[self.userImageView3 sd_setImageWithURL:[NSURL URLWithString:md3.avatar]];
|
||||
return;
|
||||
}else if (model.top_users.count == 2){
|
||||
self.userImageView1.hidden = NO;
|
||||
self.userImageView2.hidden = NO;
|
||||
self.userImageView3.hidden = YES;
|
||||
md1 = model.top_users[0];
|
||||
md2 = model.top_users[1];
|
||||
[self.userImageView1 sd_setImageWithURL:[NSURL URLWithString:md1.avatar]];
|
||||
[self.userImageView2 sd_setImageWithURL:[NSURL URLWithString:md2.avatar]];
|
||||
return;
|
||||
}else{
|
||||
self.userImageView1.hidden = NO;
|
||||
self.userImageView2.hidden = YES;
|
||||
self.userImageView3.hidden = YES;
|
||||
md1 = model.top_users[0];
|
||||
[self.userImageView1 sd_setImageWithURL:[NSURL URLWithString:md1.avatar]];
|
||||
}
|
||||
|
||||
}else{
|
||||
self.countLabel.hidden = YES;
|
||||
self.userCountLabel.hidden = YES;
|
||||
self.userImageView1.hidden = YES;
|
||||
self.userImageView2.hidden = YES;
|
||||
self.userImageView3.hidden = YES;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
@end
|
||||
140
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.xib
Normal file
140
QXLive/Mine(音域)/View/礼物墙/QXMineGiftWallCell.xib
Normal file
@@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="QXMineGiftWallCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="168" height="236"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="168" height="236"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="user_giftwall_light" translatesAutoresizingMaskIntoConstraints="NO" id="7cD-Zp-duy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="168" height="236"/>
|
||||
</imageView>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lFd-KA-CIy">
|
||||
<rect key="frame" x="22" y="17" width="124" height="124"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="lFd-KA-CIy" secondAttribute="height" multiplier="1:1" id="7wf-ev-960"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="共计0个" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gu5-Ab-anM">
|
||||
<rect key="frame" x="119" y="6" width="39" height="11"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="11" id="VFO-2d-XS3"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="10"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="荣耀冠军" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C99-P7-2Qa">
|
||||
<rect key="frame" x="5" y="143" width="158" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="flQ-Sl-76q"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="6dg-55-CAQ">
|
||||
<rect key="frame" x="66" y="211" width="18" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="SU0-l9-dWa"/>
|
||||
<constraint firstAttribute="width" constant="18" id="YcQ-Cd-n5d"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="9"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="mxk-cv-aBW">
|
||||
<rect key="frame" x="54" y="211" width="18" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="18" id="Kwg-ZJ-I5s"/>
|
||||
<constraint firstAttribute="height" constant="18" id="xl5-Rc-fQg"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Rfn-Wi-s2Q">
|
||||
<rect key="frame" x="42" y="211" width="18" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="18" id="n8I-xi-ccY"/>
|
||||
<constraint firstAttribute="height" constant="18" id="pmp-Ws-KWh"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="等12人" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5R5-ei-HVw">
|
||||
<rect key="frame" x="90" y="214.66666666666666" width="70" height="11"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="11" id="iAF-7r-aTF"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="10"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wfH-dA-6iW">
|
||||
<rect key="frame" x="5" y="163" width="158" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="Nbj-v3-IdB"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
||||
<state key="normal" title=" 666" image="mine_live_gift_corn">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstItem="mxk-cv-aBW" firstAttribute="centerY" secondItem="6dg-55-CAQ" secondAttribute="centerY" id="64c-V4-gA0"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Gu5-Ab-anM" secondAttribute="trailing" constant="10" id="7T4-Ob-NXO"/>
|
||||
<constraint firstItem="C99-P7-2Qa" firstAttribute="top" secondItem="lFd-KA-CIy" secondAttribute="bottom" constant="2" id="EDD-kB-qDv"/>
|
||||
<constraint firstItem="lFd-KA-CIy" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="22" id="Fy1-9f-QQe"/>
|
||||
<constraint firstItem="mxk-cv-aBW" firstAttribute="leading" secondItem="Rfn-Wi-s2Q" secondAttribute="trailing" constant="-6" id="GJa-tY-ixM"/>
|
||||
<constraint firstAttribute="trailing" secondItem="C99-P7-2Qa" secondAttribute="trailing" constant="5" id="GMT-PY-7GW"/>
|
||||
<constraint firstAttribute="trailing" secondItem="wfH-dA-6iW" secondAttribute="trailing" constant="5" id="Gfa-T9-bdP"/>
|
||||
<constraint firstItem="wfH-dA-6iW" firstAttribute="top" secondItem="C99-P7-2Qa" secondAttribute="bottom" constant="2" id="H7F-rR-suC"/>
|
||||
<constraint firstItem="6dg-55-CAQ" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" constant="-9" id="IEG-br-wSV"/>
|
||||
<constraint firstAttribute="bottom" secondItem="6dg-55-CAQ" secondAttribute="bottom" constant="7" id="NPv-mt-kE9"/>
|
||||
<constraint firstItem="Gu5-Ab-anM" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="6" id="NcQ-DB-e4d"/>
|
||||
<constraint firstAttribute="bottom" secondItem="7cD-Zp-duy" secondAttribute="bottom" id="Oct-d8-K8j"/>
|
||||
<constraint firstAttribute="trailing" secondItem="7cD-Zp-duy" secondAttribute="trailing" id="Qa8-XB-CzO"/>
|
||||
<constraint firstItem="7cD-Zp-duy" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="YDV-W0-g0C"/>
|
||||
<constraint firstAttribute="trailing" secondItem="lFd-KA-CIy" secondAttribute="trailing" constant="22" id="YOB-Ja-o1M"/>
|
||||
<constraint firstItem="5R5-ei-HVw" firstAttribute="leading" secondItem="6dg-55-CAQ" secondAttribute="trailing" constant="6" id="Ylg-Ai-WXn"/>
|
||||
<constraint firstItem="wfH-dA-6iW" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="5" id="bRU-wK-9Wa"/>
|
||||
<constraint firstItem="C99-P7-2Qa" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="5" id="ccB-et-MDe"/>
|
||||
<constraint firstItem="5R5-ei-HVw" firstAttribute="centerY" secondItem="6dg-55-CAQ" secondAttribute="centerY" id="fnx-YY-rbh"/>
|
||||
<constraint firstItem="6dg-55-CAQ" firstAttribute="leading" secondItem="mxk-cv-aBW" secondAttribute="trailing" constant="-6" id="mXP-d3-zvO"/>
|
||||
<constraint firstItem="7cD-Zp-duy" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="mZY-P3-rUD"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5R5-ei-HVw" secondAttribute="trailing" constant="8" id="t0r-L7-IXx"/>
|
||||
<constraint firstItem="Rfn-Wi-s2Q" firstAttribute="centerY" secondItem="mxk-cv-aBW" secondAttribute="centerY" id="tKT-zK-45J"/>
|
||||
<constraint firstItem="lFd-KA-CIy" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="17" id="tf1-7W-W8b"/>
|
||||
</constraints>
|
||||
<size key="customSize" width="168" height="236"/>
|
||||
<connections>
|
||||
<outlet property="bgImageView" destination="7cD-Zp-duy" id="Qws-Sx-zgv"/>
|
||||
<outlet property="countLabel" destination="Gu5-Ab-anM" id="thX-Ow-8uq"/>
|
||||
<outlet property="giftCoinBtn" destination="wfH-dA-6iW" id="0Pf-vR-YFG"/>
|
||||
<outlet property="giftImageView" destination="lFd-KA-CIy" id="WHj-IT-1gB"/>
|
||||
<outlet property="nameLabel" destination="C99-P7-2Qa" id="4Pi-Pd-bat"/>
|
||||
<outlet property="userCountLabel" destination="5R5-ei-HVw" id="o6Z-tG-hWI"/>
|
||||
<outlet property="userImageView1" destination="6dg-55-CAQ" id="Vuh-HH-6hU"/>
|
||||
<outlet property="userImageView2" destination="mxk-cv-aBW" id="faK-sf-NvT"/>
|
||||
<outlet property="userImageView3" destination="Rfn-Wi-s2Q" id="gBa-p4-JDT"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="229.00763358778624" y="85.211267605633807"/>
|
||||
</collectionViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="mine_live_gift_corn" width="10" height="10"/>
|
||||
<image name="user_giftwall_light" width="108" height="149"/>
|
||||
</resources>
|
||||
</document>
|
||||
Reference in New Issue
Block a user