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

  • Home
  • SEARCH
  • 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 642373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:09:50+00:00 2026-05-13T21:09:50+00:00

I am searching about drawing bordered text on UIView. Implemented following method : –

  • 0

I am searching about drawing bordered text on UIView.

Implemented following method :

- (void)drawRect:(CGRect)rect { 
    //TODO draw bordered text here. 
}

How to draw it ?

I mean each letter is bordered of whole text.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 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-13T21:09:51+00:00Added an answer on May 13, 2026 at 9:09 pm

    To display bordered text (if I understand correctly what you want) you should set text drawing mode to kCGTextFillStroke (and set appropriate values for text drawing parameters, such as stroke and fill colors etc)

    // Choose appropriate text font
    CGContextSelectFont(context, [[UIFont boldSystemFontOfSize:24].fontName UTF8String], (int)fontSize, kCGEncodingMacRoman);
    // Set text drawing mode 
    CGContextSetTextDrawingMode(context, kCGTextFillStroke);
    // Set appropriate color/line width values
    // Here we're set to draw white letters with black border
    CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
    CGContextSetRGBFillColor(context, 1, 1, 1, 1);
    CGContextSetLineWidth(context, 1);
    // Set this transformations or text will be displayed upside-down
    CGAffineTransform xform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
    CGContextSetTextMatrix(context, xform);
    // Display text
    CGContextShowTextAtPoint(...);
    

    Edit: As Quartz does not work well with unicode, to draw unicode strings you’ll need to use other APIs. I managed to draw “bordered” unicode string using NSAttributedString and OHAttributedLabel (thanks to this answer for that custom control). Sample code to get required string in some view controller:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSMutableAttributedString *s = [[NSMutableAttributedString alloc] initWithString:@"您好世界"];
        [s addAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:-3.0f] forKey:(NSString*)kCTStrokeWidthAttributeName]
                   range:NSMakeRange(0, [s length])];
    
        [s addAttributes:[NSDictionary dictionaryWithObject:(id)[UIColor greenColor].CGColor forKey:(NSString*)kCTStrokeColorAttributeName]
                   range:NSMakeRange(0, [s length])];
    
        [s addAttributes:[NSDictionary dictionaryWithObject:(id)[UIColor redColor].CGColor forKey:(NSString*)kCTForegroundColorAttributeName]
                   range:NSMakeRange(0, [s length])];
    
        [s setFont:[UIFont boldSystemFontOfSize:28.0f]];
        [s setTextColor:[UIColor redColor]];
    
        OHAttributedLabel *l = [[OHAttributedLabel alloc] initWithFrame:CGRectMake(40.0f, 40.0f, 200.0f, 80.0f)];
        l.centerVertically = YES;
        [l setAttributedText: s];
        [self.view addSubview: l];
        [l release];
    }
    

    Note that you’ll need to link with CoreText.framework to make that work, and code uses some convenience methods provided in OHAttributedLabel implementation

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

Sidebar

Related Questions

I was searching here about converting a string like 16:20 to a DateTime type
I am drawing graphs into a WinForms Picturebox. Now I am searching for a
Searching for some sample code for converting a point in WGS84 coordinate system to
Searching for a string within a string is extremely well supported in .NET but
Searching on Google reveals x2 code snippets. The first result is to this code
Im searching a tool which allows me to specify some folders as bookmarks and
While searching the interweb for a solution for my VB.net problems I often find
After searching online, the best solution I've found so far is to just make
Im searching for the best way to mantain combo box values within a Mysql
Im searching a Template Lib or Template Engine for generating HTML (XML) that runs

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.