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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:52:33+00:00 2026-06-08T08:52:33+00:00

I am trying to bring my CATextLayer text (which is a number 1) in

  • 0

I am trying to bring my CATextLayer text (which is a number “1”) in center of view, but what I got is very small text and not in center as shown in this image. Red circle shown is a CALayer object itself which is animated, so I dont want to add text as sublayer to it. Instead I added as sublayer to view. The code I wrote for CATextLayer is:

CATextLayer *numbers = [CATextLayer layer];

numbers.string = @"1";
numbers.font = [UIFont fontWithName:@"Arial" size:100.0];
numbers.foregroundColor = [UIColor blackColor].CGColor;
numbers.bounds = CGRectMake(0, 0, 200, 200);
numbers.position = self.view.center;
numbers.wrapped = NO;

[self.view.layer addSublayer:numbers];

I hope my Question is clear. Please tell me where am I mistaken? Thanks alot.

  • 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-08T08:52:36+00:00Added an answer on June 8, 2026 at 8:52 am

    Edit

    The font property takes a CGFontRef and not a UIFont. You can create one using CGFontCreateWithFontName( (CFStringRef)@"ArialMT" ). The font size is set using the fontSize property.

    Original answer

    The correct font name is "ArialMT"1. Since you are using a non-existing font name the text gets the default font and size.

    The layer is in fact centered and 200 by 200 points2. The problem is that the text is not centered inside the text layer, instead the text is in the upper left corner. A bigger font could make it look like it’s almost centered but it still wouldn’t be.

    You can change how the content of the layer (in your case the text) is drawn relative to the bounds of the layer by changing the contentsGravity of the layer to something like kCAGravityCenter if you want the text to appear centered inside the frame of the text layer


    1. iOS Fonts is a great resource for the names you should use to get certain fonts.
    2. This can easily be verified by giving the text layer a strong background color like clear blue (since your circle is red)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ive being trying to cope with this problem but still. I need your help.
Im trying to attach a picture with and Intent.putExtra, but im not really sure
Got a weird one here. Site is deployed into production and trying to bring
I'm trying to bring the value of text entered in the label telephoneidLabel to
Here is the javascript function in which I am trying to bring about a
I'm trying to bring the typing cursor to beginning of the input text by
So I'm way behind on this one. Apple is trying to bring another figure
I am trying to bring up Linux-3.4.1 on our cutom MIPS based hardware. It
I'm trying to bring a C++ library into C#, so naturally I am trying
I have been trying out the MoreLikeThis Bundle to bring back a set of

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.