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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:14:37+00:00 2026-06-09T05:14:37+00:00

In UIView if you do the following: CAGradientLayer *layer = [CAGradientLayer layer]; layer.colors =

  • 0

In UIView if you do the following:

CAGradientLayer *layer = [CAGradientLayer layer];
layer.colors = [NSArray arrayWithObjects:(id) [UIColor colorWithRed:0 green:0 blue:0.1 alpha:1].CGColor,[UIColor colorWithRed:0.3 green:0.3 blue:0.74 alpha:1].CGColor, nil];
layer.frame=CGRectMake(0, 0, self.frame.size.width,self.frame.size.height);
[self.layer insertSublayer:layer atIndex:0];

Will drawRect then perform custom drawing on top of this gradient? Does drawRect affect the actual background of a view, or is it a different layer entirely? If the background color of the view is clearColor does drawRect still display?

  • 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-09T05:14:38+00:00Added an answer on June 9, 2026 at 5:14 am

    A sublayer obscures the content of its superlayer. If you override drawRect: to draw content, that content will be obscured by the gradient layer.

    If you want to draw the gradient behind your (view) content, you should either draw the gradient in your drawRect: instead of using a sublayer, or use a container view that contains both the gradient layer and your drawRect:-using content view, with your content view on top.

    Also, if you want the gradient layer to cover your view, it would be better to initialize layer.frame like this:

    layer.frame = self.bounds;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the following code inside an NSTimer selector: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2.0];
i am using the following method in a uiview subclass: [self performSelector:@selector(timeout) withObject:nil afterDelay:20];
I am trying to animate an image using following code: [UIView beginAnimations:nil context:NULL]; [UIView
So I'm applying an image mask to a UIView layer with the following code:
I have the following code in an .mm file: [UIView animateWithDuration:0.3 animations:^{ self.titleLabel.alpha =
If I use the following to add a UIView subclass in the subviews collection:
I am starting to learn to use UIView animation. So I wrote the following
I am searching about drawing bordered text on UIView. Implemented following method : -
UIView has the properties frame , bounds , center , and origin , and
I am getting the following error: - (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSUInteger)index reusingView:(UIView *)view {

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.