Skip to content

类似美团、大众首页滑动菜单,简单易用

License

Notifications You must be signed in to change notification settings

yanfj/YANScrollMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YANScrollMenu

License MIT CocoaPods CocoaPods

GIF

Requirements

  • ARC
  • iOS 8.0+

Cocoapods

YANScrollMenu is available via Cocoapods, add this line in your podfile :

pod 'YANScrollMenu', '~> 1.0.1'

Usage

1. Import the class :

#import "YANScrollMenu.h"

2. Simply initialize a YANScrollMenu the same way you set up a regular UIView:

self.menu = [[YANScrollMenu alloc] initWithFrame:CGRectMake(0, 0, 375,150) delegate:self];
# add to view
[self.view addSubview:self.menu];
    
# you can also set to be a tableHeaderView
self.tableView.tableHeaderView = self.menu;

3. YANScrollMenuDataSource must be adopted :

# the number of items in each section
- (NSUInteger)scrollMenu:(YANScrollMenu *)menu numberOfItemsInSection:(NSInteger)section;

# the number of section
- (NSUInteger)numberOfSectionsInScrollMenu:(YANScrollMenu *)menu;

# the dataSource of item
- (id<YANObjectProtocol>)scrollMenu:(YANScrollMenu *)scrollMenu objectAtIndexPath:(NSIndexPath *)indexPath;

4. There're also some function in YANScrollMenuDelegate that can be used to customize:

# the size of item 
- (CGSize)itemSizeOfScrollMenu:(YANScrollMenu *)menu;
   
# the customize view to set to be the header  in each section
- (UIView *)scrollMenu:(YANScrollMenu *)menu headerInSection:(NSUInteger)section;
 
# the height of header    
- (CGFloat)heightOfHeaderInScrollMenu:(YANScrollMenu *)menu;
   
# the height of pageControl  
- (CGFloat)heightOfPageControlInScrollMenu:(YANScrollMenu *)menu;

# automatic update frame or not
- (BOOL)shouldAutomaticUpdateFrameInScrollMenu:(YANScrollMenu *)menu;
   
# the callback when the item did selected  
- (void)scrollMenu:(YANScrollMenu *)menu didSelectItemAtIndexPath:(NSIndexPath *)indexPath;

5. Custom appearance :

# the icon size of item
[[YANMenuItem appearance] setIconSize:30];

# the cornerRadius of icon
[[YANMenuItem appearance] setIconCornerRadius:15];

# the textFont of the  label
[[YANMenuItem appearance] setTextFont:[UIFont systemFontOfSize:12]];

# the textColor of the  label
[[YANMenuItem appearance] setTextColor:[UIColor darkTextColor]];

# the space between icon and label
[[YANMenuItem appearance] setSpace:5];

Dependency

YANScrollMenu depend on SDWebImage and Masonry. Notes : When the version of SDWebImage large than 3.8.2 , gif will not be supported.

License

YANScrollMenu is released under the MIT license. See LICENSE file for details.

Contact

Any suggestion or question? Please create a Github issue .

About

类似美团、大众首页滑动菜单,简单易用

Resources

License

Stars

Watchers

Forks

Packages

No packages published