NSString *str = @"您也可以手动输入MAC地址";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
// Add attribute NSUnderlineStyleAttributeName
[attributedStringaddAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, str.length)];
[attributedStringaddAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, str.length)];
[attributedStringaddAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, 4)];
[attributedStringaddAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRGBHex:0X428aea] range:NSMakeRange(4, str.length-4)];
CGSize size = [strsizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-size.width)/2, SCREEN_HEIGHT-80,size.width, 50)];
[labelsetLineBreakMode:NSLineBreakByWordWrapping];
[labelsetBackgroundColor:[UIColor clearColor]];
[labelsetTextAlignment:NSTextAlignmentCenter];
[labelsetAttributedText:attributedString];
// [bgView addSubview:label];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonsetAttributedTitle:attributedString forState: UIControlStateNormal];
button.frame=CGRectMake((SCREEN_WIDTH-size.width)/2,SCREEN_HEIGHT-80,size.width,50);
[buttonaddTarget:self action:@selector(typeMacAddress) forControlEvents:UIControlEventTouchUpInside];
[bgViewaddSubview:button];
网友评论