TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jul 2015 |
Maintained by Jonathan Crooke.
Depends on: | |
Aspects | ~> 1.4.1 |
ObjcAssociatedObjectHelpers | ~> 2.0.0 |
Want to display an arbitrary UIView
on your UICollectionView
when in an empty state, and in a loosely-coupled fashion? Look no further.
#import "UICollectionView+EmptyState.h"
and simply set the property emptyState_view
on your UICollectionView
instance. We do the rest. Note that your view will be resized to overlay the UICollectionView
so be sure to properly configure beforehand.
@property (nonatomic, strong) UIView *emptyState_view;
set your overlay view.@property (nonatomic, assign) BOOL emptyState_shouldRespectSectionHeader;
when used with UICollectionViewFlowLayout
, setting this property to YES
causes the overlay to be laid-out beneath the first section's header view. This would be useful if your first section's header contains controls that affect the collection's content in some way. We don't want to block those. The demo application has a switch in its header view to demonstrate that the section header will be available for user interaction.@property (nonatomic, assign) NSTimeInterval emptyState_showAnimationDuration;
, @property (nonatomic, assign) NSTimeInterval emptyState_hideAnimationDuration;
the overlay can be faded in and out using these properties. Set either to 0 for no animation.UICollectionViewEmptyStateDelegate
protocol can be used for further customisation of the view as it's added and removed.setEmptyStateImageViewWithImage:
creates a UIImageView
with the provided image, sets it as emptyState_view
, and returns it for any further customisation required.shouldNilViewIfNotRequired
flag, to automatically nil
the empty state view if it is not added as part of the next layout cycle.-setTranslatesAutoresizingMaskIntoConstraints:
.-layoutSubviews
for UICollectionView
instances with an empty state view set.will~
delegate methods are now called from within animation blocks.contentInsets
for better iOS 7 compatibility.emptyState_shouldRespectSectionHeader
.libextobjc
.emptyState_view
explicitly so should protect against multiple nested add/remove operations and generally smoother operation.emptyState_showDelay
and emptyState_hideDelay
properties to add a delay to show/hide of the overlay.UICollectionViewEmptyStateDelegate
protocol.setEmptyStateImageViewWithImage:
.Have fun!