This commit is contained in:
启星
2025-08-08 10:49:36 +08:00
parent 6400cf78bb
commit b5ce3d580a
8780 changed files with 978183 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
//
// QXDynamicCommentCell.h
// QXLive
//
// Created by 启星 on 2025/6/4.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QXDynamicCommentCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIView *topCornerView;
@property (weak, nonatomic) IBOutlet UIView *bottomCornerView;
@property (nonatomic,strong)QXDynamicCommentListModel *model;
@property (nonatomic,copy)void(^longPressBlock)(QXDynamicCommentListModel *model);
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
+(instancetype)cellWithTableView:(UITableView *)tableView;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,61 @@
//
// QXDynamicCommentCell.m
// QXLive
//
// Created by on 2025/6/4.
//
#import "QXDynamicCommentCell.h"
@implementation QXDynamicCommentCell
+(instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *cellId = @"QXDynamicCommentCell";
QXDynamicCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject;
cell.backgroundColor = [UIColor clearColor];
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:cell action:@selector(handleLongPress:)];
[cell addGestureRecognizer:longPress];
}
return cell;
}
-(void)setModel:(QXDynamicCommentListModel *)model{
_model = model;
NSString *commentUser = @"";
if (model.reply_to_user.length == 0) {
commentUser = [NSString stringWithFormat:@"%@",model.nickname];
}else{
commentUser = [NSString localizedStringWithFormat:QXText(@"%@ 回复 %@"),model.nickname,model.reply_to_user];
}
NSString* content = [NSString stringWithFormat:@"%@%@",commentUser,model.content];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:content];
[attr yy_setColor:RGB16(0x999999) range:[content rangeOfString:model.content]];
[attr yy_setColor:RGB16(0x333333) range:[content rangeOfString:commentUser]];
self.commentLabel.attributedText = attr;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.createtime.longLongValue]; //,1000 , 1000
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSString*time = [formatter stringFromDate:date];
self.timeLabel.text = time;
}
-(void)handleLongPress:(UILongPressGestureRecognizer *)gesture{
if (gesture.state == UIGestureRecognizerStateBegan) {
if (self.longPressBlock) {
self.longPressBlock(self.model);
}
}
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end

View File

@@ -0,0 +1,127 @@
<?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="Safe area layout guides" minToolsVersion="9.0"/>
<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"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="141" id="KGk-i7-Jjw" customClass="QXDynamicCommentCell">
<rect key="frame" x="0.0" y="0.0" width="428" height="141"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="428" height="141"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xpB-b7-lGw">
<rect key="frame" x="64" y="0.0" width="348" height="141"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wj3-tk-zlh">
<rect key="frame" x="0.0" y="0.0" width="348" height="24"/>
<color key="backgroundColor" red="0.97647058819999999" green="0.97647058819999999" blue="0.97647058819999999" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="VRd-E6-wjg"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ujm-d6-5zi">
<rect key="frame" x="0.0" y="12" width="348" height="117"/>
<color key="backgroundColor" red="0.97647058819999999" green="0.97647058819999999" blue="0.97647058819999999" alpha="1" colorSpace="calibratedRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tn3-vd-O5b">
<rect key="frame" x="0.0" y="117" width="348" height="24"/>
<color key="backgroundColor" red="0.97647058819999999" green="0.97647058819999999" blue="0.97647058819999999" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="WbI-tI-87v"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MH7-oM-77U">
<rect key="frame" x="12" y="12" width="324" height="98"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ovO-RW-ILy">
<rect key="frame" x="12" y="116" width="31" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="PFb-yy-Wz2"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.57647058823529407" green="0.57647058823529407" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BDR-Dd-yF8">
<rect key="frame" x="53" y="116" width="38" height="20"/>
<color key="backgroundColor" red="0.96078431372549022" green="0.96078431372549022" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="38" id="DYo-ky-Mwr"/>
<constraint firstAttribute="height" constant="20" id="P7V-zS-ieb"/>
</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="回复">
<color key="titleColor" red="0.57647058823529407" green="0.57647058823529407" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="5"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</button>
</subviews>
<constraints>
<constraint firstItem="MH7-oM-77U" firstAttribute="top" secondItem="xpB-b7-lGw" secondAttribute="top" constant="12" id="7HG-rN-ZXB"/>
<constraint firstItem="ovO-RW-ILy" firstAttribute="top" secondItem="MH7-oM-77U" secondAttribute="bottom" constant="6" id="CDA-7f-DI4"/>
<constraint firstItem="wj3-tk-zlh" firstAttribute="top" secondItem="xpB-b7-lGw" secondAttribute="top" id="CtL-8c-2EE"/>
<constraint firstItem="Tn3-vd-O5b" firstAttribute="top" secondItem="Ujm-d6-5zi" secondAttribute="bottom" constant="-12" id="DXX-9k-jtw"/>
<constraint firstAttribute="trailing" secondItem="Ujm-d6-5zi" secondAttribute="trailing" id="FoU-Ue-edq"/>
<constraint firstAttribute="bottom" secondItem="Tn3-vd-O5b" secondAttribute="bottom" id="GrF-LO-MKV"/>
<constraint firstItem="wj3-tk-zlh" firstAttribute="leading" secondItem="xpB-b7-lGw" secondAttribute="leading" id="KIq-S2-f5X"/>
<constraint firstAttribute="trailing" secondItem="MH7-oM-77U" secondAttribute="trailing" constant="12" id="LbR-uJ-Rnz"/>
<constraint firstItem="BDR-Dd-yF8" firstAttribute="centerY" secondItem="ovO-RW-ILy" secondAttribute="centerY" id="Pl5-d4-uSY"/>
<constraint firstAttribute="trailing" secondItem="wj3-tk-zlh" secondAttribute="trailing" id="WM9-UL-gVo"/>
<constraint firstAttribute="trailing" secondItem="Tn3-vd-O5b" secondAttribute="trailing" id="XBe-4U-aAO"/>
<constraint firstItem="Tn3-vd-O5b" firstAttribute="leading" secondItem="xpB-b7-lGw" secondAttribute="leading" id="Z1D-TT-RqS"/>
<constraint firstItem="Ujm-d6-5zi" firstAttribute="top" secondItem="wj3-tk-zlh" secondAttribute="bottom" constant="-12" id="foT-ME-nSA"/>
<constraint firstItem="BDR-Dd-yF8" firstAttribute="leading" secondItem="ovO-RW-ILy" secondAttribute="trailing" constant="10" id="nVH-R6-2RG"/>
<constraint firstItem="Ujm-d6-5zi" firstAttribute="leading" secondItem="xpB-b7-lGw" secondAttribute="leading" id="nqu-b6-z28"/>
<constraint firstAttribute="bottom" secondItem="ovO-RW-ILy" secondAttribute="bottom" constant="5" id="tAa-xh-nWW"/>
<constraint firstItem="MH7-oM-77U" firstAttribute="leading" secondItem="xpB-b7-lGw" secondAttribute="leading" constant="12" id="vi3-5m-DoP"/>
<constraint firstItem="ovO-RW-ILy" firstAttribute="leading" secondItem="xpB-b7-lGw" secondAttribute="leading" constant="12" id="z0e-oe-D3t"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="xpB-b7-lGw" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="64" id="3Yn-bs-fOw"/>
<constraint firstItem="xpB-b7-lGw" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="D52-la-m9V"/>
<constraint firstAttribute="bottom" secondItem="xpB-b7-lGw" secondAttribute="bottom" id="Ohy-Rl-W1F"/>
<constraint firstAttribute="trailing" secondItem="xpB-b7-lGw" secondAttribute="trailing" constant="16" id="cP3-J2-kVq"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="bottomCornerView" destination="Tn3-vd-O5b" id="Wgj-q4-Hzn"/>
<outlet property="commentLabel" destination="MH7-oM-77U" id="d4v-SC-qU7"/>
<outlet property="timeLabel" destination="ovO-RW-ILy" id="lPo-Fk-HLc"/>
<outlet property="topCornerView" destination="wj3-tk-zlh" id="xnW-5L-NJs"/>
</connections>
<point key="canvasLocation" x="221.37404580152671" y="32.74647887323944"/>
</tableViewCell>
</objects>
</document>

View File

@@ -0,0 +1,25 @@
//
// QXDynamicCommentHeaderView.h
// QXLive
//
// Created by 启星 on 2025/6/4.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol QXDynamicCommentHeaderViewDelegate <NSObject>
@optional
-(void)didClickDeleteComment:(QXDynamicCommentListModel*)model;
-(void)didClickReplyComment:(QXDynamicCommentListModel*)model;
@end
@interface QXDynamicCommentHeaderView : UIView
@property (nonatomic,strong)QXDynamicCommentListModel *model;
@property (nonatomic,weak)id<QXDynamicCommentHeaderViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,128 @@
//
// QXDynamicCommentHeaderView.m
// QXLive
//
// Created by on 2025/6/4.
//
#import "QXDynamicCommentHeaderView.h"
@interface QXDynamicCommentHeaderView()
@property (nonatomic,strong)UIImageView *headerImageView;
@property (nonatomic,strong)UILabel *nameLabel;
@property (nonatomic,strong)UILabel *contentLabel;
@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong)UIButton *replyBtn;
@property (nonatomic,strong)UIButton *deleteBtn;
@end
@implementation QXDynamicCommentHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.headerImageView = [[UIImageView alloc] init];
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.headerImageView addRoundedCornersWithRadius:20];
[self addSubview:self.headerImageView];
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.height.width.mas_equalTo(40);
make.top.mas_equalTo(12);
}];
self.nameLabel = [[UILabel alloc] init];
self.nameLabel.textColor = [UIColor blackColor];
self.nameLabel.font = [UIFont systemFontOfSize:12];
[self addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.headerImageView.mas_right).offset(7);
make.height.mas_equalTo(16);
make.top.mas_equalTo(12);
make.right.mas_equalTo(-16);
}];
self.contentLabel = [[UILabel alloc] init];
self.contentLabel.textColor = [UIColor blackColor];
self.contentLabel.font = [UIFont systemFontOfSize:14];
self.contentLabel.numberOfLines = 0;
[self addSubview:self.contentLabel];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.nameLabel);
make.top.equalTo(self.nameLabel.mas_bottom).offset(7);
make.right.mas_equalTo(-16);
}];
self.timeLabel = [[UILabel alloc] init];
self.timeLabel.textColor = RGB16(0x939393);
self.timeLabel.font = [UIFont systemFontOfSize:12];
[self addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.nameLabel);
make.height.mas_equalTo(20);
make.top.equalTo(self.contentLabel.mas_bottom).offset(2);
}];
self.replyBtn = [[UIButton alloc] init];
[self.replyBtn setTitle:QXText(@"回复") forState:(UIControlStateNormal)];
self.replyBtn.titleLabel.font = [UIFont systemFontOfSize:12];
[self.replyBtn setTitleColor:RGB16(0x939393) forState:(UIControlStateNormal)];
[self.replyBtn addRoundedCornersWithRadius:5];
self.replyBtn.backgroundColor = RGB16(0xF5F5F5);
[self.replyBtn addTarget:self action:@selector(replyAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.replyBtn];
[self.replyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeLabel.mas_right).offset(12);
make.height.mas_equalTo(20);
make.width.mas_equalTo(ScaleWidth(38));
make.centerY.equalTo(self.timeLabel);
}];
self.deleteBtn = [[UIButton alloc] init];
[self.deleteBtn setTitle:QXText(@"删除") forState:(UIControlStateNormal)];
self.deleteBtn.titleLabel.font = [UIFont systemFontOfSize:12];
[self.deleteBtn setTitleColor:RGB16(0x939393) forState:(UIControlStateNormal)];
[self.deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.deleteBtn];
[self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.replyBtn.mas_right).offset(6);
make.height.mas_equalTo(20);
make.width.mas_equalTo(ScaleWidth(38));
make.centerY.equalTo(self.timeLabel);
}];
}
-(void)setModel:(QXDynamicCommentListModel *)model{
_model = model;
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.nameLabel.text = model.nickname;
self.contentLabel.text = model.content;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.createtime.longLongValue]; //,1000 , 1000
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSString*time = [formatter stringFromDate:date];
self.timeLabel.text = time;
if ([model.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
self.deleteBtn.hidden = NO;
}else{
self.deleteBtn.hidden = YES;
}
}
-(void)replyAction{
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickReplyComment:)]) {
[self.delegate didClickReplyComment:self.model];
}
}
-(void)deleteAction{
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickDeleteComment:)]) {
[self.delegate didClickDeleteComment:self.model];
}
}
@end

View File

@@ -0,0 +1,27 @@
//
// QXDynamicCommentInputView.h
// QXLive
//
// Created by 启星 on 2025/6/4.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol QXDynamicCommentInputViewDelegate <NSObject>
@optional
-(void)didClickSendWithText:(NSString*)text model:(QXDynamicCommentListModel*)model;
@end
@interface QXDynamicCommentInputView : UIView
@property (nonatomic,strong)UITextField *textField;
@property (nonatomic,strong)QXDynamicCommentListModel *model;
@property (nonatomic,weak)id<QXDynamicCommentInputViewDelegate>delegate;
-(void)inputBecomeFirstResponder;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,113 @@
//
// QXDynamicCommentInputView.m
// QXLive
//
// Created by on 2025/6/4.
//
#import "QXDynamicCommentInputView.h"
@interface QXDynamicCommentInputView()<UITextFieldDelegate>
@property (nonatomic,strong)UICollectionView *collectionViwew;
@property (nonatomic,strong)UIView *inputBgView;
@property (nonatomic,strong)UIView *inputShadowView;
@property (nonatomic,strong)UIButton *sendBtn;
@end
@implementation QXDynamicCommentInputView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.backgroundColor = [UIColor whiteColor];
self.sendBtn = [[UIButton alloc] init];
self.sendBtn.needEventInterval = 0.5;
[self.sendBtn setTitle:QXText(@"发送") forState:(UIControlStateNormal)];
self.sendBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.sendBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.sendBtn.backgroundColor = QXConfig.themeColor;
[self.sendBtn addRoundedCornersWithRadius:17.5];
[self.sendBtn addTarget:self action:@selector(sendAction) forControlEvents:(UIControlEventTouchUpInside)];;
[self addSubview:self.sendBtn];
[self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-16);
make.top.mas_equalTo(8);
make.height.mas_equalTo(35);
make.width.mas_equalTo(80);
}];
self.inputBgView = [[UIView alloc] init];
self.inputBgView.backgroundColor = RGB16(0xF5F5F5);
[self.inputBgView addRoundedCornersWithRadius:8];
[self addSubview:self.inputBgView];
[self.inputBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.right.equalTo(self.sendBtn.mas_left).offset(-12);
make.centerY.equalTo(self.sendBtn);
make.height.mas_equalTo(35);
}];
self.textField = [[UITextField alloc] init];
self.textField.font = [UIFont systemFontOfSize:14];
self.textField.textColor = QXConfig.textColor;
self.textField.returnKeyType = UIReturnKeyDone;
self.textField.delegate = self;
[self.textField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
[self.inputBgView addSubview:self.textField];
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(10);
make.right.mas_equalTo(-10);
make.top.bottom.equalTo(self.inputBgView);
}];
self.inputShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 4)];
self.inputShadowView.backgroundColor = [UIColor whiteColor];
self.inputShadowView.layer.shadowColor = [UIColor grayColor].CGColor;
self.inputShadowView.layer.shadowOpacity = 0.2;
self.inputShadowView.layer.shadowOffset = CGSizeMake(0, -2);
self.inputShadowView.layer.shadowRadius = 2;
self.inputShadowView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.inputShadowView.bounds cornerRadius:self.inputShadowView.layer.cornerRadius].CGPath;
self.inputShadowView.layer.cornerRadius = 2;
self.inputShadowView.layer.masksToBounds = NO;
[self addSubview:self.inputShadowView];
// self.inputShadowView.layer.shadowColor = [UIColor grayColor].CGColor;
// self.inputShadowView.layer.shadowOpacity = 0.5;
// self.inputShadowView.layer.shadowOffset = CGSizeMake(0, -2);
//// self.inputShadowView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:0].CGPath;
// self.inputShadowView.layer.masksToBounds = NO;
}
-(void)textDidChange:(UITextField*)textField{
if (textField.text.length>50) {
showToast(@"评论不得超过50个字符");
textField.text = [textField.text substringToIndex:50];
}
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(void)setModel:(QXDynamicCommentListModel *)model{
_model = model;
}
-(void)inputBecomeFirstResponder{
[self.textField becomeFirstResponder];
}
-(void)sendAction{
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickSendWithText:model:)]) {
[self.delegate didClickSendWithText:self.textField.text model:self.model];
}
}
@end