0
您好我有麻烦编写一个自定义的方法添加属性为NSMutableAttributeString通过传递字符串,int和颜色作为参数,我得到三个错误,请帮助..编写一个添加属性方法在目标C
-(NSMutableAttributedString*)setAttributedSuits: (NSString*) suitString
setwidth:(id)strokeWidth
setColor:(id)strokeColor{
NSMutableAttributedString* attributeSuits = [[NSMutableAttributedString alloc]initWithString:suitString];
if ([strokeWidth isKindOfClass:[NSString class]]&&[strokeWidth isKindOfClass:[UIColor class]]) // error 1 - use of undeclared identifier "UIColor", did you mean '_color'?
{
[attributeSuits addAttributes:@{NSStrokeWidthAttributeName:strokeWidth, // error 2 - use of undeclared identifier "NSStrokeWidthAttributeName"
NSStrokeColorAttributeName:strokeColor} //// error 3 - use of undeclared identifier "NSStrokeColorAttributeName"
range:NSMakeRange(0, suitString.length)];
}
return attributeSuits;
}
感谢rmaddy的建议,它现在工作正常。我对编程非常陌生,有什么建议可以改善我的代码?非常感谢 –
看到我更新的答案。 – rmaddy
非常感谢您的意见! –