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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:37+00:00 2026-06-13T02:36:37+00:00

I have subclassed the UICollectionViewLayoutAttributes class and added a few custom properties. In my

  • 0

I have subclassed the UICollectionViewLayoutAttributes class and added a few custom properties.

In my custom UICollectionViewLayout class, I am overriding the static
+ (Class)layoutAttributesClass and I return my new attributes class.

In my UICollectionViewLayout class I override the -(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect and I set the values to the custom properties.

I can inspect the attributes class right there and see that the custom properties are set properly.

So, lastly I need to retrieve these properties in the UICollectionViewCell, so I override the -(void) applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes to fetch the values in the custom UICollectionViewLayoutAttributes class, YET they are nil. As if I never set them.

All the rest of the attributes are working perfectly, including transforms and such. So clearly, Im doing something wrong. Please advise.

Included is the HeaderFile of my custom class

@interface UICollectionViewLayoutAttributesWithColor : UICollectionViewLayoutAttributes

@property (strong,nonatomic) UIColor *color;

@end

and here is the implementation. As you can see, nothing special

@implementation UICollectionViewLayoutAttributesWithColor

@synthesize color=_color;

@end
  • 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-13T02:36:38+00:00Added an answer on June 13, 2026 at 2:36 am

    you will be glad to know the answer is simple. You just need to override copyWithZone: as the UICollectionViewAttributes implements the NSCopying protocol. What’s happening is Apple code is making copies of your custom attributes object, but because you haven’t implemented copyWithZone, your custom attributes are not being copied to the new object. Here’s an example of what you need to do:

    @interface IRTableCollectionViewLayoutAttributes : UICollectionViewLayoutAttributes {
        CGRect _textFieldFrame;
    }
    
    @property (nonatomic, assign) CGRect  textFieldFrame;
    
    @end
    

    and the implementation:

    - (id)copyWithZone:(NSZone *)zone
    {
        IRTableCollectionViewLayoutAttributes *newAttributes = [super copyWithZone:zone];
        newAttributes->_textFieldFrame = _textFieldFrame;
    
        return newAttributes;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom PDFDocument class where I have subclassed - (Class)pageClass and return
I have subclassed UIViewController into a new class, PageViewController (I'm writing a simple book
I have subclassed UIScrollView and added my own custom delegate (currently called delegate ).
I have subclassed a control in C# WinForms, and am custom drawing text in
We have subclassed the Silverlight Application class to add some additional functionality and then
I have subclassed a UITableViewCell and within this class I want to get it's
I have subclassed UITableViewCell to make a custom cell for a tableView. I add
I have subclassed UITableViewCell for a custom cell view along the lines as follows:
I have subclassed QLabel as follows: class TestLabel: public QLabel { Q_OBJECT public: TestLabel(QWidget
I have a UITableViewSource which I have subclassed. I'm overriding GetCell and using my

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.