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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:48:23+00:00 2026-06-04T12:48:23+00:00

I have a CAShapeLayer that I’m using to draw tiny dots in a bar

  • 0

I have a CAShapeLayer that I’m using to draw tiny dots in a bar chart. The problem is that they are all too big on the retina displays. I have set the contentsScale and checked that it is getting set. Still I see no difference with it or without it!

CAShapeLayer *lineShapeLayer = [CAShapeLayer layer];
lineShapeLayer.contentsScale = [[UIScreen mainScreen] scale]; 
CGMutablePathRef path = CGPathCreateMutable();
lineShapeLayer.backgroundColor = [UIColor clearColor].CGColor;
lineShapeLayer.bounds = CGRectMake(0, 0, self.backgroundLayer.bounds.size.width, 1.5);

lineShapeLayer.anchorPoint = CGPointMake(0, 0);
lineShapeLayer.position = CGPointMake(0, rint((self.verticalPartitionHeight)*i));
lineShapeLayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:1], [NSNumber numberWithInt:2], nil];
lineShapeLayer.strokeColor = [UIColor blackColor].CGColor;
lineShapeLayer.lineWidth = 1;
NSLog(@"contentsScale: %f", lineShapeLayer.contentsScale);

CGPathMoveToPoint(path, nil, 0, .5);       
CGPathAddLineToPoint(path, nil, lineShapeLayer.frame.size.width, .5);
[lineShapeLayer setPath:path];

[self.backgroundLayer addSublayer:lineShapeLayer];

Here is the view if I make it with PNGs:
PNGs showing 1px dots

Here is the view with the CAShapeLayer code (set to line width .5 even.):
CAShapeLayer showing 4px dots :(

  • 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-04T12:48:25+00:00Added an answer on June 4, 2026 at 12:48 pm

    There is nothing wrong with you code unless its somewhere else. I ran the code above inside a loop (I’m assuming i is the index) with self.verticalPartitionHeight = 30.0.

    The two images below are the result in both normal resolution and retina resolution. I’ve scaled up the normal image to make them the same size. The dots are, as you can see, the same size (in points, not pixels) on both resolutions.

    Normal resolution, scaled up two times

    Retina resolution

    Edit:

    You mention that the Stocks app does this in Landscape but if you zoom in on a screenshot of it you will actually see that it actually uses points (since every dot is 2×2 pixels). You can see this in the screenshot below (from a retina screenshot) where I zoomed in a lot on the dots and selected one pixel of one dot.

    This is the expected behavior.

    Stocks.app dots

    Edit 2:

    One more zoomed up look at your dots. They are actually the exact same size as the dots in Apples Stocks app. You can see it in the image below where I have selected one pixel.

    enter image description here

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

Sidebar

Related Questions

I have created a spider chart by overiding draw rect, I am using core
Have a look at one of my websites: moskah.com The problem is that it
I have a CAShapeLayer that takes his shape from path. This creates a layer
I have a UITableViewCell that I've added a gradient to by using CAGradientLayer. This
I have a UIView that contains a drawing that I've made using CALayers added
I have problem related with question I've set contentsScale and after that text looking
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have a matrix report now that has Position, Hours and Wages for a location
Have you ever had to justify the choice over using .NET instead of Java
Have a rather abstract question for you all. I'm looking at getting involved in

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.