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 withUICollectionViewFlowLayout
, setting this property toYES
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.- A convenience method
setEmptyStateImageViewWithImage:
creates aUIImageView
with the provided image, sets it asemptyState_view
, and returns it for any further customisation required.
- The overlay does not rotate terribly well at this time.
- Added
shouldNilViewIfNotRequired
flag, to automaticallynil
the empty state view if it is not added as part of the next layout cycle.
- Added new delegate method that allows modification of the proposed overlay frame.
- Permit Autolayout, by removing call to
-setTranslatesAutoresizingMaskIntoConstraints:
.
- Changed swizzling solution to Aspects, in order to only swizzle
-layoutSubviews
forUICollectionView
instances with an empty state view set. - Improved some other property and layout logic, including in the demo.
- Fixed an incorrect pointer bug.
- Proper overhaul with recreated project. No more test suite demons.
will~
delegate methods are now called from within animation blocks.- Better sizing when respecting the collection's first section header. Takes account of header sizing for the layout and delegate. Does not access the actual header view at all.
- Demo is prettier and more functional.
- Tidying up podspec dependencies.
- Much-needed spring clean.
- Properly respects the collection view's
contentInsets
for better iOS 7 compatibility. - Accesses the collection view's section 0 header view directly for more robust layout with
emptyState_shouldRespectSectionHeader
. - Scrolling of the collection view is now disabled when the overlay is visible.
- Scrolls the collection back to the top when the overlay is presented.
- Dependency updates.
- Updated depedencies for changes in
libextobjc
.
- Fixed missing QuartzCore import.
- Checks the animation keys for the
emptyState_view
explicitly so should protect against multiple nested add/remove operations and generally smoother operation.
- Added
emptyState_showDelay
andemptyState_hideDelay
properties to add a delay to show/hide of the overlay. - Possibly fixed a retain cycle-related crash issue.
- Test target currently broken and no time to fix... :(
- Dependency updates.
- Fixed dependency error.
- Tidying of methods.
- Existing empty views are always removed when a new view is set. Allows for more dynamic changing of empty state views.
- Added
UICollectionViewEmptyStateDelegate
protocol. - Added
setEmptyStateImageViewWithImage:
. - 0.0.1 - Initial release
Have fun!