我不知道你要應用的效果(有幾個例子/截圖在你的鏈接上)。
但在這裏你可以做或者設置爲你想了什麼(應用所需的值):
NSAttributedString *originalUserNamePlaceHolder = logInViewController.logInView.usernameField.attributedPlaceholder;
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowBlurRadius:2.0];
[shadow setShadowColor:[UIColor grayColor]];
[shadow setShadowOffset:CGSizeMake(0, 2.0)];
NSDictionary *attributesCustom = @{NSShadowAttributeName: shadow, NSForegroundColorAttributeName:theUIColorYouWant};
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"customText" attributes: attributesCustom];
logInViewController.logInView.usernameField.attributedPlaceholder = attrString;
注意customText
可能是[originalUserNamePlaceHolder string];
你可以閱讀更多關於你的婉的各種效果適用here。現在
,你可以這樣做來檢索要模仿(因爲你喜歡它)的設置,檢索其具體設置:
__block NSDictionary *attributesRetrieved;
[attrString enumerateAttributesInRange:NSMakeRange(0, [attrString length]) options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop)
{
NSLog(@"Attrs: %@", attrs);
attributesRetrieved = [attrs copy];
}];
應該只有一個屬性(對於整個文本)。 例如,在一個我設置: 你有:
attributesRetrieved:{
NSColor = 「1 UIDeviceWhiteColorSpace 1」;
NSShadow =「NSShadow {0,2} blur = 2 color = {UIDeviceWhiteColorSpace 0.5 1}」;
} 因此,您可以檢索之前放置的設置。