pragma mark - 重画tableview的线
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
//下分割线
CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor);
CGContextStrokeRect(context, CGRectMake(0, rect.size.height, rect.size.width, 1));
}
pragma mark - 如何给UILabel添加中线
UILabel * strikeLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString *textStr = [NSString stringWithFormat:@"%@元", primeCost];
//中划线
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
// 赋值
strikeLabel.attributedText = attribtStr;
[self.view addSubview:strikeLabel];
pragma mark - 如何给UILabel添加下划线
UILabel *underlineLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString *textStr = [NSString stringWithFormat:@"%@元", primeCost];
// 下划线
NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
//赋值
underlineLabel.attributedText = attribtStr;
[self.view addSubview:underlineLabel];
pragma mark - 创建Button下划线
UIButton *button = [[UIButtonalloc]initWithFrame:CGRectMake(0,0, KScreenWidth,25)];
[button setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
[button setBackgroundColor:[UIColorcolorWithRed:239.0/255.0green:152.0/255.0blue:121.0/255.0alpha:1]];
[button.titleLabel setFont:[UIFont systemFontOfSize:10]];
NSMutableAttributedString *title = [[NSMutableAttributedStringalloc] initWithString:@"号源紧俏经常预约不上?试试预约抢号功能? >>"];
NSRange titleRange = {0, [titlelength]};
[title addAttribute:NSUnderlineStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlineStyleSingle]range:titleRange];
[button setAttributedTitle:titleforState:UIControlStateNormal];
[button addTarget:selfaction:@selector(buttonAction:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];