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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:21:30+00:00 2026-05-26T15:21:30+00:00

I’ve been looking to embellishing a UIScrollView by adding some kind of shadow around

  • 0

I’ve been looking to embellishing a UIScrollView by adding some kind of shadow around the content, visible when the view is greater than the content. Safari does this using grey gradients around the page (pinch to make a webpage smaller and pan to see the gradients at the edges)

There are lots of discussions on a similar topic but they all seem to discuss solutions for UITableView (gradients above and below the content), not UIScrollView which requires gradients around all four edges.

I initially used a layer effect (see below) but this visibly affected performance and pan & zoom became jumpy, especially with Retina display, so I removed it.

ChartView *chartView = [[ChartView alloc] initWithChild:child type:type];
// Give it a nice shadow -- Unfortunately this kills performance, especially on Retina phones
aChartView.layer.masksToBounds = NO;
aChartView.layer.shadowOffset = CGSizeMake(10, 12);
aChartView.layer.shadowRadius = 20;
aChartView.layer.shadowOpacity = 0.6;
// Create the scroll view (root view)
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;   // Allow automatic resizing in orientation changes
scrollView.backgroundColor = [UIColor lightGrayColor];
scrollView.delegate = self;
[scrollView addSubview:chartView];

I tried subclassing UIScrollView and overriding drawRect and was able to draw a background, but it only gets called once so I cannot adjust the background as the content moves/resizes.

Safari doesn’t use a shadow, but some kind of gradient (which, incidentally, look slightly imperfect at the corners if you look very carefully), maybe this gives better perf. Anybody knows how they do this?

EDIT

This issue is now resolved and I have put my implementation of this (a subclass of UIScrollView which adds Safari-style gradient shadows to it) on GitHub for readers who are looking for the same thing: https://github.com/Clafou/ShadowedScrollView

  • 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-26T15:21:31+00:00Added an answer on May 26, 2026 at 3:21 pm

    I think you’re right that the corners are the problem. I know that using layer.cornerRadius really kills performance and I would assume that shadowRadius probably does, too.

    Possibly the better option is to do what it looks like Safari does, which is add a CAGradientLayer on all four sides. With Safari, they started the gradient behind the view so that the corners would still be shaded, but it has the side effect of making them look a little weird. However, this is probably the least graphically intensive way to do it.

    Finding an example for a CAGradientLayer is pretty easy. The default is a vertical gradient. To make it a horizontal gradient, just set the start and end points:

    gradient.startPoint = CGPointMake(0, 0.5);
    gradient.endPoint = CGPointMake(1.0, 0.5);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.