2013-10-27 94 views
1

下面的示例应该用填充绘制笔画,但不是。哪里不对?根据苹果公司的文档,我正在使用负面价值来显示。如果我把它看成一个正值,那么文本就完全消失了。NSAttributedString使用NSStrokeColorAttributeName和NSStrokeWidthAttributeName绘制无笔画设置

UITextView *rte = [[UITextView alloc]initWithFrame: 
            CGRectMake(50,50,100,100)]; 

[self.view addSubview:rte]; 
NSDictionary *typingAttributes = @{ 
            NSFontAttributeName: [UIFont fontWithName:@"Helvetica-Bold" size:20.0f], 
            NSForegroundColorAttributeName : [UIColor redColor], 
            NSStrokeColorAttributeName : [UIColor yellowColor], 
            NSStrokeWidthAttributeName : [NSNumber numberWithFloat:-2.0] 
            }; 
NSAttributedString *str = [[NSAttributedString alloc] 
          initWithString:@"Enter text here..." 
          attributes:typingAttributes]; 
rte.attributedText = str; 

回答

1

我曾尝试你的代码中的iOS 7.0.3模拟器,并得到了结果: enter image description here

它不是在IOS 6的工作,我认为这是一个错误。 This approach is working

对不起,我没有任何解释为什么在iOS 6中它不起作用。

+0

iOS 7模拟器也适用于我 - 你是对的。但iOS 6不...为什么? – Vad

+0

我发现了类似的问题:https://discussions.apple.com/thread/4873320 – Vad