• Stars
    star
    486
  • Rank 87,487 (Top 2 %)
  • Language
    Objective-C
  • License
    BSD 2-Clause "Sim...
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

UICollectionViewLayout for displaying electronic program guide.

Introduction

INSElectronicProgramGuideLayout was written by Michaล‚ Zaborowski for inspace.io

INSElectronicProgramGuideLayout

INSElectronicProgramGuideLayout is a UICollectionViewLayout subclass for displaying Electronic Program Guide.

Example

The example project create sample data for the next three days channel data, it use LoremIpsum framework to fill EPG data. To run, build and run the Example target in from INSElectronicProgramGuideLayout.xcworkspace within the Example directory.

Usage

CocoaPods

Add the following to your Podfile and run $ pod install.

pod 'INSElectronicProgramGuideLayout'

If you don't have CocoaPods installed, you can learn how to do so here.

Invalidating Layout

If you change the content of your INSElectronicProgramGuideLayout, make sure to call the invalidateLayoutCache method. This flushes the internal caches of your INSElectronicProgramGuideLayout, allowing the data to be repopulated correctly.

Collection View Elements

INSElectronicProgramGuideLayout has eleven different elements that you should register UICollectionReusableView and UICollectionViewCell classes for. They are:

  • EPG Cell (UICollectionViewCell) โ€“ Represents your events.
  • Channel Column Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindSectionHeader) โ€“ Contains the channel text, top aligned.
  • Hour Row Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHourHeader) โ€“ Contains the hour text, center aligned.
  • Half Hour Row Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHalfHourHeader) โ€“ Contains the half hour text, center aligned.
  • Channel Column Header Background (UICollectionReusableView) element kind of (INSEPGLayoutElementKindSectionHeaderBackground) โ€“ Background of the channel column header.
  • Hour Row Header Background (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHourHeaderBackground) โ€“ Background of the hour row header.
  • Current Time Indicator (UICollectionReusableView) element kind of (INSEPGLayoutElementKindCurrentTimeIndicator) โ€“ Displayed over the hour row header, aligned at the current time.
  • Current Time Vertical Gridline (UICollectionReusableView) element kind of (INSEPGLayoutElementKindCurrentTimeIndicatorVerticalGridline) โ€“ Displayed under the cells, aligned to the current hour.
  • Vertical Hour Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindVerticalGridline) โ€“ Displayed under the cells, aligns with its corresponding hour row header.
  • Vertical Half Hour Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHalfHourVerticalGridline) โ€“ Displayed under the cells, aligns with its corresponding half hour row header.
  • Horizontal Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHorizontalGridline) โ€“ Displayed under the cells, aligns with its corresponding channel column header.
  • Floating Overlay (UICollectionReusableView) element kind of (INSEPGLayoutElementKindFloatingItemOverlay) โ€“ Displayed over the cells, aligns with its content.

Interface and customization

@interface INSElectronicProgramGuideLayout : UICollectionViewLayout

/**
*  Vertical space between sections (channels)
*/
@property (nonatomic, assign) CGFloat sectionGap;

/**
*  Section size
*/
@property (nonatomic, assign) CGFloat sectionHeight;
@property (nonatomic, assign) CGFloat sectionHeaderWidth;

/**
*  Current time indicator and gridline size
*/
@property (nonatomic, assign) CGSize currentTimeIndicatorSize;
@property (nonatomic, assign) CGFloat currentTimeVerticalGridlineWidth;

/**
*  Gridlines size
*/
@property (nonatomic, assign) CGFloat horizontalGridlineHeight;
@property (nonatomic, assign) CGFloat verticalGridlineWidth;

/**
*  Hour width and hour header height
*/
@property (nonatomic, assign) CGFloat hourWidth;
@property (nonatomic, assign) CGFloat hourHeaderHeight;

/**
*  Default size to use for floating headers. If the delegate does not implement the collectionView:layout:sizeForFloatingItemOverlayAtIndexPath: method, the flow layout uses the value in this property to set the size of each floating header.
*/
@property (nonatomic, assign) CGSize floatingItemOverlaySize;

/**
* Horizontal space between floating header and section.
Default value is 10.0
*/
@property (nonatomic, assign) CGFloat floatingItemOffsetFromSection;

/**
* Distances between the border and the layout content view.
* Default value is UIEdgeInsetsMake(0, 0, 0, 0)
*/
@property (nonatomic, assign) UIEdgeInsets contentMargin;

/**
*  Margin between cells.
*  Default value is UIEdgeInsetsMake(0, 0, 0, 10)
*/
@property (nonatomic, assign) UIEdgeInsets cellMargin;

@property (nonatomic, assign) INSElectronicProgramGuideLayoutType headerLayoutType;

/**
*  Set to YES if you want to resize sticky background headers when UICollectionView bounces.
*/
@property (nonatomic, assign) BOOL shouldResizeStickyHeaders;

/**
*  Set to YES if you want to use floting overlay to each cell. If set to YES you have to register supplementaryViewOfKind INSEPGLayoutElementKindFloatingItemOverlay.
*/
@property (nonatomic, assign) BOOL shouldUseFloatingItemOverlay;

Can I call performBatchUpdates:completion: to make stuff animate?

Don't do this. It doesn't work properly, and is a "bag of hurt".

Requirements

INSElectronicProgramGuideLayout requires either iOS 7.x and above.

Special thanks

I'd love a thank you tweet if you find this useful.

Special thanks to Eric Horacek who was originally wrote MSCollectionViewCalendarLayout, and i took many stuff from him.

Storyboard

INSElectronicProgramGuideLayout supports storyboard.

ARC

INSElectronicProgramGuideLayout uses ARC.

Contact

inspace.io

Twitter

License

Copyright (c) 2014 inspace.io. All rights reserved.

It is open source and covered by a standard 2-clause BSD license. That means you have to mention inspace.io as the original author of this code and reproduce the LICENSE text inside your app.

You can purchase a Non-Attribution-License for 35 Euros for not having to include the LICENSE text.

We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.

More Repositories

1

MZFormSheetController

MZFormSheetController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup controller size and feel form sheet.
Objective-C
2,544
star
2

MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
Objective-C
976
star
3

INSPullToRefresh

A simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.
Objective-C
815
star
4

MZDayPicker

An iOS day picker to allow users to select date
Objective-C
623
star
5

WCAlertView

WCAlertView is deliverd from UIAlertView. It's support customization and blocks.
Objective-C
619
star
6

INSPhotoGallery

INSPhotoGallery is a modern looking photo gallery written in Swift for iOS.
Swift
397
star
7

MZBookshelfCollectionViewLayout

Bookshelf like iBooks layout for UICollectionView.
Objective-C
121
star
8

INSOperationsKit

Objective-C adaptation of the sample code provided in the Advanced NSOperations session of WWDC 2015
Objective-C
112
star
9

MZAppearance

UIAppearance proxy for custom objects
Objective-C
107
star
10

MZSelectableLabel

A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.
Objective-C
102
star
11

UIAlertController-MZStyle

Category for UIAlertController customization
Objective-C
94
star
12

MZFayeClient

Faye Client for iOS. Supports subscription blocks.
Objective-C
84
star
13

INSPersistentContainer

Open Source, 100% API compatible replacement of NSPersistentContainer for iOS8+
Objective-C
65
star
14

SpotifyImporter

Spotify library importer into Apple Music
Objective-C
55
star
15

WCBeforeAfter

Objective-C BeforeAfter
Objective-C
52
star
16

INSNibLoading

A UIView/NSView category and a subclass for loading custom view from UINib (xib) files
Objective-C
27
star
17

source-tree-custom-commands

A collection of SourceTree CustomActions.
Shell
20
star
18

AccessibilityIdentificable

Identifiers for UI testing: a reflection based approach
Swift
20
star
19

RWMAmazonProductAdvertisingManager

AFNetworking Client for Amazon Product Advertising API
Objective-C
13
star
20

ContextWatcher

Example which shows how to observe changes on single NSManagedObject instance
Swift
13
star
21

RWMVimeoClient

AFNetworking Client for Vimeo Advanced API
Objective-C
12
star
22

CCTouchableSprite

Touchable CCSprite for cocos2d framework with Objective-C Blocks
Objective-C
7
star
23

xcode-themes

My Xcode themes
1
star