2014-06-17 36 views
0

所以我想在Parse LoginView控制器中更改用户名占位符,但文本显示为模糊 - 如何设置正确的阴影/高光或...只需更改文本而不更改样式属性。下面在解析loginviewcontroller中更改占位符文本

https://parse.com/tutorials/login-and-signup-views

这两个创建一个没有正确的阴影模糊灰色文本/凸显

logInViewController.logInView.usernameField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Phone" attributes:@{}]; 

logInViewController.logInView.usernameField.placeholder = @"phone"; 

回答

0

我不知道你要应用的效果(有几个例子/截图在你的链接上)。
但在这里你可以做或者设置为你想了什么(应用所需的值):

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}”;
} 因此,您可以检索之前放置的设置。