Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 734865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:25:20+00:00 2026-05-14T07:25:20+00:00

I have to draw underlined-multiline text with all types of text alignment. I have

  • 0

I have to draw underlined-multiline text with all types of text alignment. I have searched on forums and got some results like:

http://davidjhinson.wordpress.com/2009/11/26/underline-text-on-the-iphone/

http://forums.macrumors.com/showthread.php?t=561572

But all draw text for single line only. while i have multi-line text. The situation even become worse when the text alignment is centered. I searched and found that in iphone-sdk-3.2 there are some core-text attributes for underlining a text but no idea how to use that. Besides if I use these my problem would not be solved fully.

As I have to draw strikethrough text also.

Anybody having idea about this please help.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:25:21+00:00Added an answer on May 14, 2026 at 7:25 am

    What about this. This works good for me what you all think, if this needs some optimisation?

    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);
                        }
                    }
    
                }
    

    Hope this works good for all.

    Thanks,

    Madhup

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to draw a small finite state machine that has some reflexive transitions
I have to draw a line between two points using quartz. At some point
I'd like to have Silverlight draw the blue L and C in the image
I want to draw the underline below my TextView . I have searched a
I have a model called newbie. The routes.rb file looks like: Myapp::Application.routes.draw do resources
I have integrate draw line in my application i have not used OpenGL or
I have to draw a circle in live wallpaper when it touches the boundary
Hi I am working on an application where i have to draw something. When
I have tried to draw a bar in a cell of my table. Everything
I have tried to draw Polygon using Drawing Manager and send the Polygon Coordinates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.