Skip to content

Why MagazineLayoutCollectionViewLayoutAttributes is final? #67

@AntonBelousov

Description

@AntonBelousov

The problem
I use UICollectionView with custom layout in my app. I wanted to migrate to MagazineLayout. But I use custom UICollectionViewLayoutAttributes, so I need to somehow extend MagazineLayoutCollectionViewLayoutAttributes to use with my cells.
But since MagazineLayoutCollectionViewLayoutAttributes is final - I can't just subclass it.

The solution I'd like
Make it non-final

Alternatives I've considered
a) Make MagazineLayout non-final, and let subclasses provide type of UICollectionViewLayoutAttributes which conforms to protocol:

protocol IMagazineLayoutCollectionViewLayoutAttributes {
    public var shouldVerticallySelfSize: Bool { get set}
}

Make MagazineLayoutCollectionViewLayoutAttributes conform this protocol :

extension MagazineLayoutCollectionViewLayoutAttributes: IMagazineLayoutCollectionViewLayoutAttributes {}

b) Use objc runtime to extend MagazineLayoutCollectionViewLayoutAttributes
c) Add property into MagazineLayoutCollectionViewLayoutAttributes (some key-value collection), to hold additional parameters

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions