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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:46:16+00:00 2026-06-07T05:46:16+00:00

How does iOS go about calculating a toolbar gradient? I’d like to be able

  • 0

How does iOS go about calculating a toolbar gradient? I’d like to be able to set my window’s background color to match the end color in the gradient so that it appears to fade into the view. The problem is that the end tint seems to vary depending on the base color and I can’t find a consistent formula that produces a match.

  • 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-07T05:46:17+00:00Added an answer on June 7, 2026 at 5:46 am

    My best approximation:

    (r', g', b') = (f(r), f(g), f(b)) where f(x) = 0.001468x^2 + 0.647295x + 4.04025
    

    How I derived that:
    Let c = (r, g, b) = base color.
    Let c' = (r', g', b') = resulting color.
    I let c = #944321 = (148, 67, 33) and got c' = #84361b = (132, 54, 27).

    That gives me three equations to solve:

    f(148) = 132
    f(67) = 54
    f(33) = 27
    

    Since we have three equations, let f(x) be a polynomial with three unknowns:

    f(x) = Ax^2 + Bx + C
    

    From there I made a 3×4 matrix on my calculator, inputted the different values of x, and performed a reduced-row-echelon on the matrix, the solution being (0.001468, 0.647295, 4.04025). I plug those into A, B and C and got the aforementioned f(x).

    Here’s a quick Python script to perform the calculation.

    Usage: ./script.py rrggbb

    #!/usr/bin/env python
    
    import sys
    
    def end_color(color):
        def f(x):
            return int(round(0.001468 * x ** 2 + 0.647295 * x + 4.04025))
        rgb = (int(color[i:i+2], 16) for i in xrange(0, 6, 2))
        return ''.join(hex(f(n))[2:] for n in rgb)
    
    for color in sys.argv[1:]:
        print end_color(color)
    

    I tested this with the color #9e3393 and got #8f2983, same color iOS produced:

    $ ./script.py 9e3393
    8f2983
    

    Even if it’s not exact sometimes it will probably be impossible to tell since you’re using the color at the end of a gradient. Hope that helps!

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

Sidebar

Related Questions

Does this work in > iOS 5? .element { background: url(images/myImage.jpg) 50% 0 no-repeat
Why does this fail, it's supposed to be simple and work ? fisier.seekg(0, ios::end);
An iOS app which consumes content from back end server. The content actually does
Does anyone know if it is possible to implement TTS in iOS development like
Does anyone know about Facebook checkins with the Facebook iOS SDK? I have made
How does a beginner go about practicing introspection in Cocoa programming (specifically iOS)? In
How would you go about doing this? Does the iOS API offer any functions
Does iOS offer a way for an app to query the device for information
Does iOS SDK provide a way to let iOS app talk to app running
-webkit-device-pixel-ratio query is supported by both iOS and Android but since iOS does not

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.