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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:10:02+00:00 2026-06-02T22:10:02+00:00

A plain UIView subclass, with ONLY the following code: – (id)initWithCoder:(NSCoder *)aDecoder { self

  • 0

A plain UIView subclass, with ONLY the following code:

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        // Initialization code

        CAGradientLayer* gradientLayer = [CAGradientLayer layer];
        gradientLayer.colors = [NSArray arrayWithObjects:[UIColor whiteColor], [UIColor blackColor], nil];
        gradientLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:1.0], nil];

        [self.layer addSublayer:gradientLayer];

    return self;
}

Kills the runtime with EXC_BAD_ACCESS (and no, there’s no Zombies, before you ask).

Also, it’s NOT the CAGradientLayer getting over-released – putting multiple floating retain’s on the layer has no effect.

(Incidentally, I have never seen CAGradientLayer actually work, on any project I’ve been on. I think it’s cursed :). I wouldn’t use it, except I need animated gradients, and Apple’s CGGradient class only supports const arrays, which makes the animation code horrendously bug-prone)

  • 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-02T22:10:10+00:00Added an answer on June 2, 2026 at 10:10 pm

    The problem might be here:

    gradientLayer.colors = [NSArray arrayWithObjects:[UIColor whiteColor], [UIColor blackColor], nil];
    

    Those colors need to be the Core Graphic equivalents so this might work.

    gradientLayer.colors = [NSArray arrayWithObjects:(__bridge id)[UIColor whiteColor].CGColor, (__bridge id)[UIColor blackColor].CGColor, nil]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In plain old HTML the following code will work: <input type=button value=click onClick=function() />
I have anViewA and anViewB. They're plain UIView objects with a lot of subviews.
My Plain Code without interpolation: im1 = imread('lena.jpg');imshow(im1); [m,n,p]=size(im1); thet = rand(1); m1=m*cos(thet)+n*sin(thet); n1=m*sin(thet)+n*cos(thet);
I'd like to load a plain UIView, a UIWebView and a UITableView all in
In plain English, this code kicks in when an element is hovered over. When
I have a plain project with blank UIView . Later, when I'm get some
Plain-vanilla NHibernate setup, eg, no fluent NHibernate, no HQL, nothing except domain objects and
Plain text, contact info, image are differences. So I want to know how to
In plain English, what are the disadvantages and advantages of using SET TRANSACTION ISOLATION
It is possible in plain Java to override a method of a class programmatically

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.