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 8471349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:46:19+00:00 2026-06-10T16:46:19+00:00

I am trying to draw a block of text with a stroke. So doing

  • 0

I am trying to draw a block of text with a stroke. So doing a bit of searching and experimenting seems that the way to do it is to subclass UIView and draw the text with a stroke in drawRect. The drawing code is below.

The way I have it set up, I am using a UITextView to enter the text I want interactively, then the text is passed to the UIView subclass ad drawn with a stroke.

This seems to be working perfectly. The only problem is when the return key is pressed (creating a new line), or the line wraps because it becomes too wide for the UITextView, this information is not passed, so there is no new line in my renderd (stroked) text drawn in the UIView subclass.

Any help?

Drawing code (note that theText is a property to pass the UITextView’s text to):

    UIFont *font =  [UIFont fontWithName:@"Arial" size:fontSize];
    CGPoint point = CGPointMake(0,0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
    CGContextSetLineWidth(context, 4.0);
    CGContextSetTextDrawingMode(context, kCGTextFillStroke);
    CGContextSaveGState(context);
    [theText drawAtPoint:point withFont:font];
    CGContextRestoreGState(context);
  • 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-06-10T16:46:21+00:00Added an answer on June 10, 2026 at 4:46 pm

    You must duplicate the wrapping logic of uitextview. Ask the string how long the substring needs to be, and when it gets to long to fit its going to wrap.

    You can also look at DTCoreText, a class that lets you render attributed text. However the version that mimics textviews and supports text entry costs something. In the end that cost may be worth it as duplicating a textview will take time .

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

Sidebar

Related Questions

I am trying to draw colored text in my UIView subclass. Right now I
I'm trying to draw Right-Aligned text in a custom control, however, it seems for
I'm trying to draw an 8-bit style games character (link from Zelda) as i'm
I am trying to draw bordered Text on Graphics, as shown below. The text
I'm trying to draw text without antialiasing on a canvas in Android. The font
I'm trying to draw some text in the corner of a rectangle but I
I'm trying to draw some text onto an MapView on Android. The drawing of
Basically the code is trying to take a source image, draw some custom text
Creating a DIV that uses CSS to draw a triangle to the left. Trying
I'm trying to draw text using canvas. I checked out everywhere but those examples

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.