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
非常感謝您的意見! –