Commit 6aefde39 cgx

意见反馈详情完成UI自动布局

1 个父辈 10d1c276
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
@interface FeedbackDetailController () @interface FeedbackDetailController ()
@property (nonatomic, strong) UIScrollView *detailSV; @property (nonatomic, strong) UIScrollView *detailSV;
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UIView *feedView; @property (nonatomic, strong) UIView *feedView;
@property (nonatomic, strong) UILabel *contentLab; @property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIView *imgContainerView;
@property (nonatomic, strong) UILabel *createdTimeLab; @property (nonatomic, strong) UILabel *createdTimeLab;
@property (nonatomic, strong) UIView *replyView; @property (nonatomic, strong) UIView *replyView;
@property (nonatomic, strong) UILabel *replyTitleLab; @property (nonatomic, strong) UILabel *replyTitleLab;
@property (nonatomic, strong) UILabel *replierContent; @property (nonatomic, strong) UILabel *replierContentLab;
@property (nonatomic, strong) UILabel *replierNameLab;
@property (nonatomic, strong) UILabel *replierTimeLab; @property (nonatomic, strong) UILabel *replierTimeLab;
@end @end
...@@ -30,36 +33,119 @@ ...@@ -30,36 +33,119 @@
[FeedbackRequestModel queryAdviceDetailWithAdviceID:self.advice_id completion:^(FeedbackRequestModel * _Nonnull requestModel) { [FeedbackRequestModel queryAdviceDetailWithAdviceID:self.advice_id completion:^(FeedbackRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
[self buildUI]; [self buildUI:requestModel.feedDetailModel];
} }
}]; }];
} }
- (void)buildUI { - (void)buildUI:(MyFeedDetailModel *)detailModel {
[self.view addSubview:self.detailSV]; [self.view addSubview:self.detailSV];
[self.detailSV addSubview:self.containerView];
[self.containerView addSubview:self.feedView];
[self.containerView addSubview:self.replyView];
[self.detailSV mas_makeConstraints:^(MASConstraintMaker *make) { [self.detailSV mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(0, 0, 0, 0)); make.edges.equalTo(self.view);
}];
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.detailSV);
make.width.height.equalTo(self.detailSV);
}]; }];
[self.detailSV addSubview:self.feedView];
[self.feedView mas_makeConstraints:^(MASConstraintMaker *make) { [self.feedView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.containerView).offset(15); make.top.equalTo(self.detailSV.mas_top).offset(15);
make.right.equalTo(self.containerView).offset(-15); make.left.equalTo(self.view).offset(15);
make.height.equalTo(@200); make.right.equalTo(self.view).offset(-15);
}]; }];
[self.replyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.containerView).offset(15); [self.feedView addSubview:self.contentLab];
make.right.equalTo(self.containerView).offset(-15); self.contentLab.text = detailModel.content;
make.top.equalTo(self.feedView.mas_bottom).offset(15); [self.contentLab sizeToFit];
make.height.equalTo(@200); [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.feedView).offset(8);
make.top.equalTo(self.feedView).offset(8);
make.right.equalTo(self.feedView).offset(-8);
}]; }];
BOOL hasImg = NO;
if (detailModel.content_img && detailModel.content_img.length > 0) {
hasImg = YES;
[self.feedView addSubview:self.imgContainerView];
[self.imgContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.feedView).offset(8);
make.top.equalTo(self.contentLab.mas_bottom).offset(20);
make.right.equalTo(self.feedView).offset(-8);
make.height.equalTo(@105);
}];
// 截取图片字符串链接
NSArray *imgUrls = [detailModel.content_img componentsSeparatedByString:@","];
for (int i = 0; i < imgUrls.count; i++) {
UIImageView *showIV = [[UIImageView alloc] initWithFrame:CGRectMake(i*(105 + 8), 0, 105, 105)];
showIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, .5);
[showIV yy_setImageWithURL:[NSURL URLWithString:imgUrls[i]] placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
[showIV cornerRadius:12.0];
[self.imgContainerView addSubview:showIV];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGRAction:)];
[showIV addGestureRecognizer:tapGR];
showIV.userInteractionEnabled = YES;
}
}
[self.feedView addSubview:self.createdTimeLab];
self.createdTimeLab.text = detailModel.created_at;
[self.createdTimeLab sizeToFit];
[self.createdTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.feedView).offset(-8);
make.bottom.equalTo(self.feedView).offset(-8);
make.top.equalTo(hasImg ? self.imgContainerView.mas_bottom : self.contentLab.mas_bottom).offset(39);
}];
UIView *lastView = self.feedView;
// 判断是否有回复信息
if (detailModel.replier_content && detailModel.replier_content.length > 0) {
[self.detailSV addSubview:self.replyView];
lastView = self.replyView;
[self.replyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).offset(-15);
make.top.equalTo(self.feedView.mas_bottom).offset(15);
}];
[self.replyView addSubview:self.replyTitleLab];
[self.replyTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.replyView).offset(8);
make.top.equalTo(self.replyView).offset(15);
}];
[self.replyView addSubview:self.replierContentLab];
self.replierContentLab.text = detailModel.replier_content;
[self.replierContentLab sizeToFit];
[self.replierContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replyTitleLab.mas_bottom).offset(12);
make.left.equalTo(self.replyView).offset(8);
make.right.equalTo(self.replyView).offset(-8);
}];
[self.replyView addSubview:self.replierNameLab];
self.replierNameLab.text = [NSString stringWithFormat:@"回复人:%@", detailModel.replier_name];
[self.replyTitleLab sizeToFit];
[self.replierNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replierContentLab.mas_bottom).offset(46);
make.right.equalTo(self.replyView).offset(-8);
}];
[self.replyView addSubview:self.replierTimeLab];
self.replierTimeLab.text = [NSString stringWithFormat:@"回复时间:%@", detailModel.replier_time];
[self.replierTimeLab sizeToFit];
[self.replierTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replierNameLab.mas_bottom).offset(8);
make.right.equalTo(self.replyView).offset(-8);
make.bottom.equalTo(self.replyView).offset(-15);
}];
}
[lastView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.detailSV.mas_bottom).offset(-15);
}];
}
- (void)tapGRAction:(UITapGestureRecognizer *)gr {
UIImageView *showIV = (UIImageView *)gr.view;
showIV.image;
DSLog(@"=========");
} }
#pragma mark - 品牌模式 #pragma mark - 品牌模式
...@@ -71,17 +157,12 @@ ...@@ -71,17 +157,12 @@
- (UIScrollView *)detailSV { - (UIScrollView *)detailSV {
if (!_detailSV) { if (!_detailSV) {
_detailSV = [UIScrollView new]; _detailSV = [UIScrollView new];
_detailSV.showsVerticalScrollIndicator = NO;
_detailSV.contentSize = CGSizeMake(kScreenWidth, 1000);
} }
return _detailSV; return _detailSV;
} }
- (UIView *)containerView {
if (!_containerView) {
_containerView = [UIView new];
}
return _containerView;
}
- (UIView *)feedView { - (UIView *)feedView {
if (!_feedView) { if (!_feedView) {
_feedView = [UIView new]; _feedView = [UIView new];
...@@ -91,6 +172,31 @@ ...@@ -91,6 +172,31 @@
return _feedView; return _feedView;
} }
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.numberOfLines = 0;
_contentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite);
}
return _contentLab;
}
- (UILabel *)createdTimeLab {
if (!_createdTimeLab) {
_createdTimeLab = [UILabel labWithFont:SysFont(12)];
_createdTimeLab.textAlignment = NSTextAlignmentRight;
_createdTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
}
return _createdTimeLab;
}
- (UIView *)imgContainerView {
if (!_imgContainerView) {
_imgContainerView = [UIView new];
}
return _imgContainerView;
}
- (UIView *)replyView { - (UIView *)replyView {
if (!_replyView) { if (!_replyView) {
_replyView = [UIView new]; _replyView = [UIView new];
...@@ -100,4 +206,39 @@ ...@@ -100,4 +206,39 @@
return _replyView; return _replyView;
} }
- (UILabel *)replyTitleLab {
if (!_replyTitleLab) {
_replyTitleLab = [UILabel labWithText:@"回复内容" textColor:ColorFromHex(0xF04B77) font:BoldFont(16.0)];
[_replyTitleLab sizeToFit];
}
return _replyTitleLab;
}
- (UILabel *)replierContentLab {
if (!_replierContentLab) {
_replierContentLab = [UILabel labWithFont:SysFont(14)];
_replierContentLab.numberOfLines = 0;
_replierContentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite);
}
return _replierContentLab;
}
- (UILabel *)replierNameLab {
if (!_replierNameLab) {
_replierNameLab = [UILabel labWithFont:SysFont(12)];
_replierNameLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
_replierNameLab.textAlignment = NSTextAlignmentRight;
}
return _replierNameLab;
}
- (UILabel *)replierTimeLab {
if (!_replierTimeLab) {
_replierTimeLab = [UILabel labWithFont:SysFont(12)];
_replierTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
_replierTimeLab.textAlignment = NSTextAlignmentRight;
}
return _replierTimeLab;
}
@end @end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!