我不知道你要应用的效果(有几个例子/截图在你的链接上)。
但在这里你可以做或者设置为你想了什么(应用所需的值):
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}”;
} 因此,您可以检索之前放置的设置。