forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShopGoodsInfoView.m
More file actions
166 lines (130 loc) · 5.71 KB
/
ShopGoodsInfoView.m
File metadata and controls
166 lines (130 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//
// ShopGoodsInfoView.m
// Coding_iOS
//
// Created by liaoyp on 15/11/21.
// Copyright © 2015年 Coding. All rights reserved.
//
#import "ShopGoodsInfoView.h"
#import "DashesLineView.h"
#define FONT(F) [UIFont systemFontOfSize:F]
@interface ShopGoodsInfoView()
{
UIImageView *_coverView;
UILabel *_priceLabel;
UILabel *_titleLabel;
UILabel *_descLabel;
UILabel *_countLabel;
UIButton *_codingCoinView;
}
@end
@implementation ShopGoodsInfoView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setUpContentView];
}
return self;
}
- (void)setUpContentView
{
UIView *superView = self;
_coverView = [[UIImageView alloc] initWithFrame:CGRectZero];
_coverView.backgroundColor = [UIColor colorWithHexString:@"0xe5e5e5"];
_coverView.contentMode = UIViewContentModeScaleAspectFill;
_coverView.layer.masksToBounds =YES;
[superView addSubview:_coverView];
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_titleLabel.font = FONT(15);
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
[superView addSubview:_titleLabel];
_descLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_descLabel.font = [UIFont systemFontOfSize:12];
_descLabel.numberOfLines = 0 ;
_descLabel.backgroundColor = [UIColor clearColor];
_descLabel.textColor = [UIColor colorWithHexString:@"0x999999"];
[superView addSubview:_descLabel];
_countLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_countLabel.font = FONT(12);
_countLabel.backgroundColor = [UIColor clearColor];
_countLabel.text = @"ⅹ1";
_countLabel.textColor = [UIColor colorWithHexString:@"0x3BBD79"];
[superView addSubview:_countLabel];
_codingCoinView = [UIButton buttonWithType:UIButtonTypeCustom];
[_codingCoinView setImage:[UIImage imageNamed:@"shop_coding_coin_icon"] forState:UIControlStateNormal];
[_codingCoinView setTitle:@" 码币 " forState:UIControlStateNormal];
[_codingCoinView setTitleColor:[UIColor colorWithHexString:@"0x222222"] forState:UIControlStateNormal];
[_codingCoinView.titleLabel setFont:[UIFont boldSystemFontOfSize:12.0]];
[superView addSubview:_codingCoinView];
float _coverViewHeight = 90;
NSLog(@"_coverViewHeight %lf",_coverViewHeight);
[_coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(superView).offset(12);
make.width.offset(_coverViewHeight);
make.height.offset(108/2);
}];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_coverView.mas_top);
make.left.equalTo(_coverView.mas_right).offset(14);
make.right.equalTo(superView.mas_right).offset(-(20+13));
}];
[_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(_titleLabel.mas_centerY);
make.right.equalTo(superView.mas_right).offset(-13);
make.width.offset(20);
}];
[_codingCoinView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_titleLabel.mas_bottom).offset(14);
make.left.equalTo(_titleLabel.mas_left);
}];
DashesLineView *lineView = [[DashesLineView alloc] init];
lineView.lineColor = [UIColor colorWithHexString:@"0xCCCCCC"];
lineView.backgroundColor = [UIColor clearColor];
[superView addSubview:lineView];
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_coverView.mas_bottom).offset(10);
make.left.equalTo(_coverView.mas_left);
make.right.equalTo(superView.mas_right).offset(-12);
make.height.offset(0.5);
}];
[_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(lineView.mas_bottom).offset(10);
make.left.right.equalTo(lineView);
}];
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_coverView.mas_top).offset(-12);
make.bottom.equalTo(_descLabel.mas_bottom).offset(12);
make.width.offset(kScreen_Width);
}];
UIView *bottomLineView = [[UIView alloc] init];
bottomLineView.backgroundColor = [UIColor colorWithHexString:@"0xC8C8C8"];
[superView addSubview:bottomLineView];
[bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.offset(0.5);
make.left.right.bottom.equalTo(superView);
}];
}
- (void)configViewWithModel:(ShopGoods *)model
{
_titleLabel.text = model.name;
NSString *points_cost = [NSString stringWithFormat:@" %@ 码币",[model.points_cost stringValue]];
[_codingCoinView setTitle:points_cost forState:UIControlStateNormal];
[_coverView sd_setImageWithURL:[model.image urlWithCodePath] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (cacheType == SDImageCacheTypeNone) {
[UIView transitionWithView:_coverView
duration:0.56
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_coverView.image = image;
} completion:^(BOOL finished) {
}];
}
}];
HtmlMedia *mHtml = [[HtmlMedia alloc] initWithString:model.description_mine showType:MediaShowTypeNone];
_descLabel.text = mHtml.contentDisplay;
CGFloat height = [self systemLayoutSizeFittingSize:UILayoutFittingExpandedSize].height;
self.frame = CGRectMake(0, 0, kScreen_Width, height);
}
@end