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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:50:24+00:00 2026-05-20T01:50:24+00:00

I have a small view with a few buttons on it. I want to

  • 0

I have a small view with a few buttons on it. I want to make this small views background a black gradient identical to the gradient when you set your UINavigation bar to Black Opaque?

Is this possible programmatically or do I need to try my best at Photoshop to copy it? 🙂

  • 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-20T01:50:24+00:00Added an answer on May 20, 2026 at 1:50 am

    Simple override drawRect message for UIView and draw background:

    - (void)drawRect:(CGRect)rect
    {
        CGContextRef context = UIGraphicsGetCurrentContext();
        GContextDrawLinearGradient(context, self.gradientLayer, CGPointMake(0.0, 0.0),
                                CGPointMake(0.0, self.frame.size.height), kCGGradientDrawsBeforeStartLocation);
    }
    

    For creating and caching gradient use this snippet (color components you should use your own).

    - (CGGradientRef)gradientLayer
    {
        if (_gradientLayer == nil)
        {
            CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
            CGFloat locations[] = { 0.0, 1.0 };
            CGFloat colors[] = { 0.0 / 255.0, 0.0 / 255.0, 48.0 / 255.0, 1.00, 26.0 / 255.0, 48.0 / 255.0, 89.0 / 255.0, 1.00 };
    
            _gradientLayer = CGGradientCreateWithColorComponents(colorSpace, colors, locations, sizeof(colors) / (sizeof(colors[0]) * 4));
            CGColorSpaceRelease(colorSpace);
        }
        return _gradientLayer;
    }
    

    And of course don’t forget release your gradient into dealloc.

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

Sidebar

Related Questions

i have small query as follows: If i will make view state property of
I have a UITableView and a small custom view. I want the custom to
I have a small app that from the home screen has a few buttons,
I have developed a small view that contains special char like 'é' and when
I have a view with two subviews: A UIImageView A small Custom View which
I have a small png that I am adding to a view which I
I have a small iPhone Project with a UITextView on my View, designed in
I have a small problem with UINavigationController animation between two view. My application build
I have started development on a small 2d adventure side view game together with
My understanding is that when you have a view that's too small to easily

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.