UIButton 添加下划线

UIButton 添加下划线_第1张图片

    
    
    self.feedBackInfo = [UIButton buttonWithType:UIButtonTypeSystem];
    
    
    NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"建议反馈"];
    NSRange titleRange = {0,[title length]};
    
    [title addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:titleRange];
    [self.feedBackInfo setAttributedTitle:title forState:UIControlStateNormal];
    [self.feedBackInfo setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.0]];
    [self.feedBackInfo setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [self.feedBackInfo.titleLabel setFont:[UIFont systemFontOfSize:20]];
    [self.feedBackInfo setTintColor:[UIColor whiteColor]];
    [self.feedBackInfo addTarget:self action:@selector(feedback:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:self.feedBackInfo];
    [self.feedBackInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgDashLineView.mas_bottom).offset(20);
        make.left.equalTo(weakSelf.view).offset(50);
        make.right.equalTo(weakSelf.view).offset(-120);
        make.height.equalTo(weakSelf.view.mas_height).multipliedBy(1/20.5f);
        
    }];
    

你可能感兴趣的:(UIButton 添加下划线)