• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 7 years ago

Reviews

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

Repository Details

Expand the current selected item. Focus the user's eyes.

DaiExpandCollectionView

Expand current selected item and catch users' eyes.

Demo

image

Overview

Unlike default UICollectionView can only display items with same fixed size, DaiExpandCollectionView can not only display items in two different sizes simultaneously but also change selected items with smooth animation.

Installation

CocoaPods

DaiExpandCollectionView is available through CocoaPods.

  • Add pod 'DaiExpandCollectionView' to your Podfile
  • Run pod install
  • Run open App.xcworkspace
  • Then #import <DaiExpandCollectionView/DaiExpandCollectionView.h>

Manually

Drag 4 source files under folder DaiExpandCollectionView\DaiExpandCollectionView\ to your project.

DaiExpandCollectionView.h
DaiExpandCollectionView.m
DaiExpandCollectionViewFlowLayout.h
DaiExpandCollectionViewFlowLayout.m

and then import the main header file:#import "DaiExpandCollectionView.h"

How to use

Step 1 : Init

DaiExpandCollectionView *daiExpandCollectionView = [DaiExpandCollectionView initWithFrame:self.view.bounds];
[daiExpandCollectionView registerClass:[ImageCollectionViewCell class] forCellWithReuseIdentifier:@"ImageCollectionViewCell"];
daiExpandCollectionView.expandDelegate = self;
[self.view addSubview:daiExpandCollectionView];

Note: Init DaiExpandCollectionView using [DaiExpandCollectionView initWithFrame:] instead of [[UICollectionView alloc] initWithFrame:collectionViewLayout:] which used by default UICollectionView.

Next, register UICollectionViewCell and then set up expandDelegate.

Step 2 : Required delegate methods

There are two required methods in DaiExpandCollectionViewDelegate

- (NSInteger)numberOfItemsInCollectionView:(UICollectionView *)collectionView;

Return the number of items (views) in the collection view.

For example:

- (NSInteger)numberOfItemsInCollectionView:(UICollectionView *)collectionView {
	return 20;
}

means there are 20 items (views) in the collection view.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;

Return a UICollectionViewCell to be displayed at the specified index in the collection view.

For example:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
	static NSString *identifier = @"ImageCollectionViewCell";
	ImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
	cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", indexPath.row + 1]];
	return cell;
}

Step 3 : Optional delegate methods

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndex:(NSInteger)index;

Return the index of current selected item. For example:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndex:(NSInteger)index {
	NSLog(@"selected : %d", index);
}

Custom

If you want use more than 3 items in row. Change your code from

self.daiExpandCollectionView = [DaiExpandCollectionView initWithFrame:frame];

to

self.daiExpandCollectionView = [DaiExpandCollectionView initWithFrame:frame itemsInRow:4];

or you can dynamic change the value itemsInRow in the run time

self.daiExpandCollectionView.itemsInRow = 5;

DaiExpandCollectionView will handle the animation automatic.

Who use it

Noooo (on App Store)

Support

  • iOS 7.0+
  • iOS 8.0+ Tested
  • iPhone / iPad
  • Vertical only

More Repositories

1

Dai-Hentai

一個普通的看漫畫 App
Objective-C
1,227
star
2

DaiMethodTracing

This is a tool for understanding your methods. You can monitor the input / output value, method relationships, method process time.
Objective-C
188
star
3

DaiNavigationTransition

Idea from http://nonomori.farbox.com/post/ios-7-jiao-hu-shi-guo-du, and convert this transition effect more easier to use.You can use this effect on ios6 !!
Objective-C
141
star
4

DaiDodgeKeyboard

Let your textfield / textview automatic dodge your keyboard.
Objective-C
85
star
5

DaiMethodHelper

A Tool for scan duplicate methods, verify method implementation, or force invoke the method!
Objective-C
68
star
6

DaiLive2DPlayground

Get a girl friend in programming
C++
66
star
7

DaiInboxHUD

這是一個模仿 google inbox 轉圈效果的 HUD
Objective-C
38
star
8

DaiDebugLog

開發者與工作夥伴的溝通利器!
Objective-C
19
star
9

DaiYoutubeParser

Parse the youtube video url path, do any custom things you want.
Objective-C
12
star
10

DispatchTimer

It is base on Dispatch Timer Source. Make it like NSTimer to use.
Objective-C
5
star
11

RuntimeSample_20150702

RuntimeSample_20150702
Objective-C
5
star
12

waifu2x-iOS

waifu2x re-implementation in C++ using OpenCV for iOS
C++
5
star
13

DaiYoutubeParserSwift

Parse the youtube video url path, do any custom things you want.
Swift
5
star
14

DaiPortalV2

Portal is a idea for transfer objects from A place to B place.
C
3
star
15

DaiSurvivor

Help your apps survive in the background!! 幫助你的 app 在背景中生存!!
Objective-C
3
star
16

DaiVolume

I DON'T want to use MPVolumeView.
Objective-C
3
star
17

RuntimeSample_20150806

RuntimeSample_20150806
C++
3
star
18

DaiFileManagerSwift

An easier way to control files. 簡單容易存取檔案
Swift
3
star
19

MoeMoeChu

Mac 端使用版本
Swift
3
star
20

htags

service e/ex tag 中文對照表, 來源自 https://github.com/Mapaler/EhTagTranslator
Go
3
star
21

DaiStorage

DaiStorage
Objective-C
2
star
22

DaiQuickPicker

DaiQuickPicker
Objective-C
2
star
23

LightWeightPlist

It is a lightweight tool allows you to easily access plist files in document / resource folder
Objective-C
2
star
24

RuntimeSample_20151015

RuntimeSample_20151015
Objective-C
2
star
25

AmiAmiReborn

上不了架的可憐 app, 用來看 amiami 的小人們
Objective-C
2
star
26

ImageFilter

圖片分類
Swift
1
star
27

InstallCloud9OnEC2

Cloud9 on EC2 安裝筆記
1
star
28

DaiBenchmark

How Much Balls Can You Display?
Swift
1
star
29

Dai36Converter

私用 36 進位計算機
Swift
1
star
30

DaiFrame

DaiFrame
Objective-C
1
star
31

DmhyRSSEnhance

Add Some Feature on Dmhy RSS
JavaScript
1
star
32

Shinsi

Shinsi is a ex-hentai viewer in Swift 2.0
Swift
1
star
33

DaiImageReplacer

DaiImageReplacer
Swift
1
star
34

DaiMultipleLevelsPicker

DaiMultipleLevelsPicker
Objective-C
1
star
35

DaiSlam

Play 3D Touch For Fun
Swift
1
star
36

PerfectChatroom

Build a easy chatroom use swift Perfect framework
Swift
1
star
37

RealmPlayground

It is my Realm Playground, just for test Realm.https://github.com/realm/realm-cocoa
Objective-C
1
star