I have been trying to underline a multiline label but I am not able to do that.
I have referred to this link but this doesn't seem to help me.
How can be done without using NSAttributedString and coreText?
I have been trying to underline a multiline label but I am not able to do that.
I have referred to this link but this doesn't seem to help me.
How can be done without using NSAttributedString and coreText?
You could use some of these open source projects from GitHub which are like UILabel
's but support an attributed string:
Following steps can be helpful.
- (void)drawRect:(CGRect)rect
Set text you want to set using this.
CGContextSetRGBFillColor(context,1.0, 0.0, 0.0, 1.0);
CGContextSetTextMatrix(context,CGAffineTransformMakeTranslation(0,pageSize.height));
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSelectFont(context, "Helvetica", 30, kCGEncodingMacRoman);
char *str=(char*)[@"TEXT" UTF8String];
CGContextShowTextAtPoint(context,476/2-200,673/2+100,str,strlen(str));
Set Line using this code.
CGContextSetLineWidth(ctx, 3);
Draw line using this code.
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, thisX, thisY);
CGContextAddLineToPoint(ctx, thatX,thatY);
CGContextStrokePath(ctx);
Hope above collected segments of code helps you....