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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:12:28+00:00 2026-05-22T22:12:28+00:00

I’ve created a document view which displays the page number in the corner. The

  • 0

I’ve created a document view which displays the page number in the corner. The page number is a uilabel with a semi-transparent background colour, and has a corner radius (using the cornerRadius property of the view‘s layer). I’ve positioned this above a UIScrollView. However, this makes scrolling jerky. If I remove the cornerRadius, performance is good. Is there anything I can do about this? What would be a better solution? It seems to have been achieved in the UIWebView without any performance issues.

  • 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-22T22:12:29+00:00Added an answer on May 22, 2026 at 10:12 pm

    For labels, or views with rounded corners and or background colors and shadows on scrolling views the solution is pretty simple:

    The biggest issue is from the masksToBounds layer option. This appears to tax performance significantly, however the label seems to need this ON to mask the background color to rounded corners. So to get around this you need to set the labels layer background color instead and switch off masksToBounds.

    The second issue is that the default behavior is to redraw the view whenever possible which is totally unnecessary with static or slow changing items on scrolling views. Here we simply set layer.shouldRasterize = YES. This will allow CA to ‘cache’ a rasterized version of the view for quick drawing when scrolling (presumably with hardware acceleration).

    You need to make sure your layer has an alpha channel otherwise rasterizing will affect the drawing of rounded corners. I’ve never had a problem as I have alpha set for my background colors, but you may need to check in your situation.

    Here is a sample UILabel set up to work nicely on a scollview:

    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(4, 4, 40.0, 24.0)];
    lbl.font = [UIFont fontWithName:@"Helvetica" size:14.0];
    lbl.textAlignment = UITextAlignmentRight;
    lbl.text = @"Hello World";
    // Must set the label background to clear so the layer background shows
    lbl.backgroundColor = [UIColor clearColor];        
    // Set UILabel.layer.backgroundColor not UILabel.backgroundColor otherwise the background is not masked to the rounded border.
    lbl.layer.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.5].CGColor;
    
    lbl.layer.cornerRadius = 8;
    lbl.layer.borderColor = [UIColor blackColor].CGColor;
    lbl.layer.borderWidth = 1;
    // Huge change in performance by explicitly setting the below (even though default is supposedly NO)
    lbl.layer.masksToBounds = NO;
    // Performance improvement here depends on the size of your view
    lbl.layer.shouldRasterize = YES;
    lbl.layer.rasterizationScale = [UIScreen mainScreen].scale;
    // self here is the child view in the scroll view
    [self addSubview:lbl];
    [lbl release];
    

    I can fill the iPad 1 screen with views like this and still scroll smoothly 🙂

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I'm making a simple page using Google Maps API 3. My first. One marker
I have a text area in my form which accepts all possible characters from

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.