//
// WJOrderDetailViewController.m
// KingTalent
//
// Created by wangjie on 2020/11/25.
// Copyright © 2020 yizhilu. All rights reserved.
//
#import "WJOrderDetailViewController.h"
#import "WJOrderDetailTopView.h"
#define infoFont [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]
@interface WJOrderDetailViewController ()
@property (strong, nonatomic) UIScrollView* scrollView;
@property (strong, nonatomic) UILabel* productName;
@property (strong, nonatomic) UILabel* transactionInfoLabel;
@end
@implementation WJOrderDetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"订单详情";
UIScrollView *scrollView = UIScrollView.new;
self.scrollView = scrollView;
scrollView.alwaysBounceVertical = YES;
scrollView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:scrollView];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self generateContent];
}
- (void)generateContent {
UIView* contentView = UIView.new;
[self.scrollView addSubview:contentView];
contentView.backgroundColor = UIColor.whiteColor;
[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollView);
make.width.equalTo(self.scrollView);
}];
// ---------- orderNum ----------
WJOrderDetailTopView * orderNum = [[WJOrderDetailTopView alloc]init];
[contentView addSubview:orderNum];
orderNum.leftLable.text = @"订单编号:2255522";
[orderNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(@0);
make.height.equalTo(@35);
make.left.right.equalTo(@0);
}];
// ---------- sep1 ----------
UIView * sep1 = [[UIView alloc]init];
[contentView addSubview:sep1];
sep1.backgroundColor = COLOR_245;
[sep1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(orderNum.mas_bottom);
make.left.right.equalTo(@0);
make.height.equalTo(@5.5);
}];
// ---------- goodsInfoV ----------
WJOrderDetailTopView * goodsInfoV = [[WJOrderDetailTopView alloc]init];
[contentView addSubview:goodsInfoV];
goodsInfoV.leftLable.text = @"商品信息";
[goodsInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(sep1.mas_bottom);
make.height.equalTo(@35);
make.left.right.equalTo(@0);
}];
// ---------- sep2 ----------
UIView * sep2 = [[UIView alloc]init];
[contentView addSubview:sep2];
sep2.backgroundColor = COLOR_245;
[sep2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(goodsInfoV.mas_bottom);
make.left.right.equalTo(@0);
make.height.equalTo(@1);
}];
/*
商品名称:基础阶段-教辅带读-预习课(第一期)
商品类型:公开课
下单时间:2018-08-22 16:30
*/
NSString * str1 = @"商品名称:基础阶段-教辅带读-预习课(第一期)\n";
NSString * str2 = @"商品类型:公开课\n";
NSString * str3 = @"下单时间:2018-08-22 16:30";
NSString * str4 = [NSString stringWithFormat:@"%@%@%@",str1,str2,str3];
// ---------- self.productName ----------
self.productName = [[UILabel alloc]init];
[contentView addSubview:self.productName];
self.productName.textColor = kTMainTitleColor;
self.productName.font = infoFont;
self.productName.numberOfLines = 0;
[self.productName mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(sep2.mas_bottom).offset(15);
make.left.equalTo(@15);
make.right.equalTo(@(-15));
}];
self.productName.text = @"商品名称";
self.productName.text = str4;
UIView * sep3 = [[UIView alloc]init];
[contentView addSubview:sep3];
sep3.backgroundColor = COLOR_245;
[sep3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.productName.mas_bottom).offset(15);
make.left.right.equalTo(@0);
make.height.equalTo(@6);
}];
// ---------- 交易信息 ----------
WJOrderDetailTopView * transactionInfoV = [[WJOrderDetailTopView alloc]init];
[contentView addSubview:transactionInfoV];
transactionInfoV.leftLable.text = @"交易信息";
[transactionInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(sep3.mas_bottom);
make.height.equalTo(@35);
make.left.right.equalTo(@0);
}];
/*
商品原价:¥0
实际金额:
*/
NSString * str5 = @"商品原价:¥0\n";
NSString * str6 = @"实际金额:\n";
NSString * str7 = [NSString stringWithFormat:@"%@%@",str5,str6];
// [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.bottom.mas_equalTo(lastView.bottom);
// }];
// ---------- 交易信息 ----------
self.transactionInfoLabel = [[UILabel alloc]init];
[contentView addSubview:self.transactionInfoLabel];
self.transactionInfoLabel.textColor = kTMainTitleColor;
self.transactionInfoLabel.font = infoFont;
self.transactionInfoLabel.numberOfLines = 0;
[self.transactionInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(transactionInfoV.mas_bottom).offset(15);
make.left.equalTo(@15);
make.right.equalTo(@(-15));
make.bottom.equalTo(@(-15));
}];
self.transactionInfoLabel.text = str7;
}
@end
//
// WJOrderDetailTopView.m
// KingTalent
//
// Created by wangjie on 2020/11/25.
// Copyright © 2020 yizhilu. All rights reserved.
//
#import "WJOrderDetailTopView.h"
@interface WJOrderDetailTopView ()
@end
@implementation WJOrderDetailTopView
// 步骤 1:重写initWithFrame:方法,创建子控件并 - 添加
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self createUI];
self.backgroundColor = UIColor.whiteColor;
}
return self;
}
- (void)createUI{
UIView * icon = [[UIView alloc]init];
[self addSubview:icon];
icon.backgroundColor = defaultBlueColor;
[icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(@0);
make.left.equalTo(@15);
make.width.equalTo(@2);
make.height.equalTo(@15);
}];
_leftLable = [[UILabel alloc]init];
[self addSubview:_leftLable];
_leftLable.textColor = kTMainTitleColor;
_leftLable.font = [UIFont boldSystemFontOfSize:15];
[_leftLable mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(@0);
make.left.equalTo(icon.mas_right).offset(6);
}];
_rightLable = [[UILabel alloc]init];
[self addSubview:_rightLable];
_rightLable.textColor = defaultBlueColor;
_rightLable.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
[_rightLable mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(@0);
make.right.equalTo(@(-15));
}];
}
@end
实现效果: