http://davidjhinson.wordpress.com/2009/11/26/underline-text-on-the-iphone/
http://forums.macrumors.com/showthread.php?t=561572
但是所有人都只为单行绘制文字.虽然我有多行文字.当文本对齐居中时,情况甚至变得更糟.我搜索并发现在iphone-sdk-3.2中有一些核心文本属性用于加下划线但不知道如何使用它.此外,如果我使用这些,我的问题将无法完全解决.
因为我还要画出删除线文字.
任何有这个想法的人请帮忙.
解决方法 那这个呢.如果这需要一些优化,这对你们有什么好处?CGContextSetFillcolorWithcolor(c,[[UIcolor blackcolor] CGcolor]); //THE TEXT color OF THE STRING TO BE DRAWN. UIFont *Fontname = [UIFont FontWithStyle:@"Arial-BoldMT" andFontSize:13]; if(FontOverLayUnderline || FontOverLayStrikeThrough){ NSArray *stringsArray = [textString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]; CGContextSetstrokecolorWithcolor(c,[appDel.textdisplayStyle.fillcolor CGcolor]); CGContextSetlinewidth(c,1.0); CGSize stringSize; Nsstring *stringToDraw; for (int i = 0 ; i < [stringsArray count]; i++) { stringToDraw = [stringsArray objectAtIndex:i]; if(![[stringToDraw stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:@""]){ stringSize = [stringToDraw sizeWithFont:Fontname forWIDth:rect.size.wIDth lineBreakMode:UIlineBreakModeCharacterWrap]; float x = rect.origin.x + (rect.size.wIDth-stringSize.wIDth)/2 + 7; float y = 4 + stringSize.height*i; [stringToDraw drawAtPoint:CGPointMake(x,y) forWIDth:stringSize.wIDth withFont:Fontname lineBreakMode:UIlineBreakModeCharacterWrap]; if(FontOverLayUnderline) y += (1.05) * stringSize.height*i +1; else y += (stringSize.height/2)+1; CGContextMovetoPoint(c,x,y); CGContextAddlinetoPoint(c,x+stringSize.wIDth,y); CGContextstrokePath(c); } } }
希望这对所有人都有益.
谢谢,
Madhup
总结以上是内存溢出为你收集整理的iphone – 画下划线/删除线文字(MULTILINE STRING)?全部内容,希望文章能够帮你解决iphone – 画下划线/删除线文字(MULTILINE STRING)?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)