项目作者: ennioma

项目描述 :
Accordion effect for UITableView
高级语言: Objective-C
项目地址: git://github.com/ennioma/EMAccordionTableViewController.git
创建时间: 2014-01-10T11:58:31Z
项目社区:https://github.com/ennioma/EMAccordionTableViewController

开源协议:MIT License

下载


EMAccordionTableViewController

N|Solid

EMAccordionTableViewController is a easy to use Expandable / Collapsable UITableView for iOS. Under the hood it works as a proxy for the UITableView and leaves
to the delegate the responsability to implement tableView:cellForRowAtIndexPath and tableView:didSelectRowAtIndexPath.

Update: Now it support the header view with parallax effect. I have used UIImage+ImageEffects from wwdc2013 to support the blur.

  • Built to be Universal
  • Support rotation
  • Completely reusable component

Apps that use the controller

How to install it?

CocoaPods

The recommended approach is to install EMAccordionTableViewController via CocoaPods.

  1. platform :ios, '6.0'
  2. pod 'EMAccordionTableViewController', '~> 0.5.4'

And then install it running

  1. $ pod install

And now open the project in Xcode from the .xcworkspace file, not from the project file

  1. $ open YourOwnProject.xcworkspace

Source Code

Alternatively you can just copy all the files included in the folder EMAccordionTable and start playing with it!

How it works?

EMAccordionTableViewController Class

  1. @interface EMAccordionTableViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>
  2. @property (nonatomic, strong) UIImage * closedSectionIcon;
  3. @property (nonatomic, strong) UIImage * openedSectionIcon;
  4. @property (nonatomic, strong) UITableView *tableView;
  5. @property (nonatomic, strong) EMAccordionTableParallaxHeaderView *parallaxHeaderView;
  6. @property (nonatomic, strong) NSMutableArray *sectionsHeaders;
  7. @property (nonatomic) NSInteger defaultOpenedSection;
  8. - (id) initWithTable:(UITableView *)tableView withAnimationType:(EMAnimationType) type;
  9. - (void) addAccordionSection: (EMAccordionSection *) section initiallyOpened:(BOOL)opened;
  10. - (void) setDelegate: (NSObject <EMAccordionTableDelegate> *) delegate;
  11. @end
  1. ### EMAccordionTableDelegate Protocol
  2. @protocol EMAccordionTableDelegate
  3. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
  4. - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
  5. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  6. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
  7. - (void) latestSectionOpened;
  8. @end

EMAccordionSection Class

  1. @interface EMAccordionSection : NSObject
  2. @property (nonatomic, strong) UIColor *backgroundColor;
  3. @property (nonatomic, strong) NSMutableArray *items;
  4. @property (nonatomic, strong) NSString *title;
  5. @property (nonatomic, strong) UIColor *titleColor;
  6. @property (nonatomic, strong) UIFont *titleFont;
  7. @end

TODO

  • Give the possibility to open a section clicking on the section itself instead of the icon
  • Give the possibility to open a section programmatically

Help me improving this!

How? Simply feel free to fork the project and improve it!

If you would like to contact me:
Twitter: ennioma.
Email: ennio.masi@gmail.com