123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // LDShareDesView.m
- // YouHuiProject
- //
- // Created by 小花 on 2019/1/2.
- // Copyright © 2019年 kuxuan. All rights reserved.
- //
- #import "LDShareDesView.h"
- @interface LDShareDesView ()
- @end
- @implementation LDShareDesView
- - (instancetype)initWithFrame:(CGRect)frame commissPrice:(NSString *)commissPrice
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews:commissPrice];
- }
- return self;
- }
- - (void)initSubViews:(NSString *)commissonPrice {
- self.backgroundColor = [UIColor clearColor];
- UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Fitsize(65), self.height)];
- NSString *comPrice = [NSString stringWithFormat:@"¥%@元",commissonPrice];
- NSString *text = [NSString stringWithFormat:@"商品被购买你可赚%@",comPrice];
- if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
- text=@"分享给好友";
- }
- title.font = [UIFont systemFontOfSize:14];
- title.textColor = [UIColor YHColorWithHex:0x666666];
- title.textAlignment = NSTextAlignmentCenter;
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
- NSRange range = [text rangeOfString:comPrice];
- [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor homeRedColor] range:range];
- title.attributedText = attStr;
- [title sizeToFit];
- title.centerX = self.width/2;
- title.centerY = self.height/2;
- [self addSubview:title];
-
- UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(title.left-70, 0, 60, 1)];
- leftLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
- leftLine.centerY = self.height/2;
- [self addSubview:leftLine];
-
- UIView *rightLine = [[UIView alloc] initWithFrame:CGRectMake(title.right+10, 0, 60, 1)];
- rightLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
- rightLine.centerY = self.height/2;
- [self addSubview:rightLine];
- }
- @end
|