Tag: 下划线

生成PDF时不显示NSAttributedString

这曾经工作,现在,突然间,它停止工作: 对于iOS 7 iPad应用程序,我生成一个PDF UIGraphicsBeginPDFContextToFile(pdfPathWithFileName, CGRectZero, nil); … UIGraphicsEndPDFContext(); 在那个代码块中,下面的方法用于渲染文本下划线,但是最近,它只是停止工作,传递给方法的任何文本都不会被渲染: +(void)drawUnderlinedText:(NSString *)text withFont:(UIFont *)font andColor:(UIColor *)color andLocationX:(int)locationX andLocationY:(int)locationY andTextAreaWidth:(int)textWidth andTextAreaHeight:(int)textHeight{ NSDictionary *attributesDict; NSMutableAttributedString *attString; attributesDict = @{NSForegroundColorAttributeName : color, NSFontAttributeName : font, NSUnderlineStyleAttributeName : [NSNumber numberWithInt:NSUnderlineStyleSingle]}; attString = [[NSMutableAttributedString alloc] initWithString:text attributes:attributesDict]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, color.CGColor); CGRect rect = CGRectMake(locationX, locationY, textWidth, textHeight); […]

从NSAttributedString下划线的UITextField只有1像素高?

标签(图片底部)和文本字段(顶部)具有相同的相同的文字。 但看看下划线。 文本字段中只有一个像素高。 这看起来很糟糕。 有谁知道是什么造成这个或如何防止它? – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { UITextField* textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 600, 200)]; NSMutableAttributedString* string = [[NSMutableAttributedString alloc]initWithString:@"The quick brown fox jumps"]; NSNumber* underlineNumber = [NSNumber numberWithInteger:NSUnderlineStyleSingle]; UIFont* font = [UIFont systemFontOfSize: 50]; [string addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, string.length)]; for (NSInteger i=0; i<20; i++) { if […]