0
我想设置一个标题以UIButton
中的自定义颜色加下划线,NSForegroundColorAttributeName: [UIColor colorWithRed:38 green:105 blue:255 alpha:1]
未应用于我的按钮。如何在iOS中设置Attributed按钮的颜色?
NSDictionary *attrDict = @{NSFontAttributeName : [UIFont systemFontOfSize:14],NSForegroundColorAttributeName : [UIColor colorWithRed:38 green:105 blue:255 alpha:1], NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};
NSMutableAttributedString *mat = [[NSMutableAttributedString alloc] initWithString:linkUrl];
[mat addAttributes:attrDict range:NSMakeRange (0, mat.length)];
[self.weblink setAttributedTitle:mat forState:UIControlStateNormal];
你真的应该申报'w'作为'CGFloat',不只是'float'所以它的类型相匹配的是'UIColor'参数。 – rmaddy