// // DRShareDesView.m // YouHuiProject // // Created by 小花 on 2019/1/2. // Copyright © 2019年 kuxuan. All rights reserved. // #import "DRShareDesView.h" @interface DRShareDesView () @end @implementation DRShareDesView - (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]; 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