设置按钮的边框颜色,添加下划线

    UIButton *selectButton = [UIButton buttonWithType:UIButtonTypeCustom];

    selectButton.frame = CGRectMake(passLabel.frame.origin.x, passLabel.frame.origin.y + passLabel.frame.size.height + 10, 20, 20); 

    //边框颜色

    [selectButton.layer setBorderWidth:1.0];

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 230/255.0, 230/255.0, 230/255.0, 1});

    [selectButton.layer setBorderColor:colorref];

//下划线

//下划线

    NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:@"按钮的文字"];

    NSRange contentRange = {0,[content length]};

    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];

    passWordButton.titleLabel.attributedText = content;

     [self addSubview:selectButton];

 

posted @ 2015-12-28 16:39  xiaolingling  阅读(459)  评论(0编辑  收藏  举报