|
@@ -28,18 +28,33 @@
|
|
|
|
|
|
self.nowPriceLb.text = model.nowPrice;
|
|
self.nowPriceLb.text = model.nowPrice;
|
|
if ([model.oldPrice isEqualToString:@""] || [model.oldPrice isEqualToString:model.nowPrice]) {
|
|
if ([model.oldPrice isEqualToString:@""] || [model.oldPrice isEqualToString:model.nowPrice]) {
|
|
- [self.oldPriceLb setHidden:true];
|
|
|
|
|
|
+// [self.oldPriceLb setHidden:true];
|
|
|
|
+ self.nowPriceLb.text = model.nowPrice;
|
|
} else {
|
|
} else {
|
|
- [self.oldPriceLb setHidden:false];
|
|
|
|
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.oldPrice]];
|
|
|
|
|
|
+// [self.oldPriceLb setHidden:false];
|
|
|
|
+
|
|
|
|
+ CGRect rect1 = [model.nowPrice boundingRectWithSize:CGSizeMake(MAXFLOAT, 22) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont fontWithName:Rob_Bold size:14]} context:nil];
|
|
|
|
+ CGRect rect2 = [model.oldPrice boundingRectWithSize:CGSizeMake(MAXFLOAT, 20) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:12]} context:nil];
|
|
|
|
+
|
|
|
|
+ NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", model.nowPrice, model.oldPrice]];
|
|
|
|
+ if (rect1.size.width + rect2.size.width + 5 > (KScreenWidth - 30)/2 - 20 - 24) {
|
|
|
|
+ attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@", model.nowPrice, model.oldPrice]];
|
|
|
|
+ }
|
|
|
|
+
|
|
[attStr addAttributes:@{
|
|
[attStr addAttributes:@{
|
|
NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:12],
|
|
NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:12],
|
|
NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle),
|
|
NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle),
|
|
NSStrikethroughColorAttributeName:Col_999,
|
|
NSStrikethroughColorAttributeName:Col_999,
|
|
NSForegroundColorAttributeName:Col_999,
|
|
NSForegroundColorAttributeName:Col_999,
|
|
- } range:NSMakeRange(0, attStr.length)];
|
|
|
|
|
|
+ } range:NSMakeRange(model.nowPrice.length + 1, model.oldPrice.length)];
|
|
|
|
+
|
|
|
|
+// CGRect rect = [attStr boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:font} context:nil];
|
|
|
|
+
|
|
|
|
|
|
- self.oldPriceLb.attributedText = attStr;
|
|
|
|
|
|
+
|
|
|
|
+ self.nowPriceLb.attributedText = attStr;
|
|
|
|
+
|
|
|
|
+// self.nowPriceLb.text = model.nowPrice;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -64,7 +79,7 @@
|
|
[self addSubview:self.titleLb];
|
|
[self addSubview:self.titleLb];
|
|
// [self addSubview:self.hotLb];
|
|
// [self addSubview:self.hotLb];
|
|
[self addSubview: self.nowPriceLb];
|
|
[self addSubview: self.nowPriceLb];
|
|
- [self addSubview: self.oldPriceLb];
|
|
|
|
|
|
+// [self addSubview: self.oldPriceLb];
|
|
[self addSubview:self.addCartBt];
|
|
[self addSubview:self.addCartBt];
|
|
|
|
|
|
[self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
[self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
@@ -86,21 +101,22 @@
|
|
[self.nowPriceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
[self.nowPriceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
[self.nowPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
[self.nowPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.equalTo(self.titleLb);
|
|
make.leading.equalTo(self.titleLb);
|
|
- make.top.greaterThanOrEqualTo(self.titleLb.mas_bottom).offset(11);
|
|
|
|
- make.height.equalTo(@17);
|
|
|
|
- make.bottom.equalTo(self.mas_bottom).offset(-9);
|
|
|
|
|
|
+ make.top.equalTo(self.titleLb.mas_bottom).offset(4);
|
|
|
|
+ make.height.mas_equalTo(@34);
|
|
|
|
+ make.right.mas_equalTo(-36);
|
|
|
|
+ make.bottom.equalTo(self.mas_bottom).offset(-6);
|
|
}];
|
|
}];
|
|
|
|
|
|
- [self.oldPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
- make.bottom.equalTo(self.nowPriceLb);
|
|
|
|
- make.leading.equalTo(self.nowPriceLb.mas_trailing).offset(4);
|
|
|
|
- make.height.equalTo(@16);
|
|
|
|
- }];
|
|
|
|
|
|
+// [self.oldPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
+// make.bottom.equalTo(self.nowPriceLb);
|
|
|
|
+// make.leading.equalTo(self.nowPriceLb.mas_trailing).offset(4);
|
|
|
|
+// make.height.equalTo(@16);
|
|
|
|
+// }];
|
|
[self.addCartBt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
[self.addCartBt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.equalTo(@24);
|
|
make.width.height.equalTo(@24);
|
|
make.trailing.equalTo(self).offset(-10);
|
|
make.trailing.equalTo(self).offset(-10);
|
|
make.bottom.equalTo(self).offset(-10);
|
|
make.bottom.equalTo(self).offset(-10);
|
|
- make.leading.greaterThanOrEqualTo(self.oldPriceLb.mas_trailing).offset(8);
|
|
|
|
|
|
+// make.leading.greaterThanOrEqualTo(self.oldPriceLb.mas_trailing).offset(8);
|
|
}];
|
|
}];
|
|
|
|
|
|
|
|
|
|
@@ -132,6 +148,8 @@
|
|
if (!_nowPriceLb) {
|
|
if (!_nowPriceLb) {
|
|
UILabel *lb = [[UILabel alloc] init];
|
|
UILabel *lb = [[UILabel alloc] init];
|
|
lb.font = [UIFont fontWithName:Rob_Bold size:14];
|
|
lb.font = [UIFont fontWithName:Rob_Bold size:14];
|
|
|
|
+// lb.adjustsFontSizeToFitWidth = YES;
|
|
|
|
+ lb.numberOfLines = 2;
|
|
lb.textColor = [UIColor blackColor];
|
|
lb.textColor = [UIColor blackColor];
|
|
lb.textAlignment = NSTextAlignmentLeft;
|
|
lb.textAlignment = NSTextAlignmentLeft;
|
|
_nowPriceLb = lb;
|
|
_nowPriceLb = lb;
|