Code Monkey home page Code Monkey logo

jhmenutableviewdemo's Introduction

JHMenuTableViewDemo

仿网易邮箱列表侧滑菜单

#目录

##如何使用?(具体请参看Demo) ####1、导入头文件 ```Objective-C #import "JHMenuTableView.h" ```

####2、TableView调用openJHTableViewMenu方法

[_tableView openJHTableViewMenu];

####3、定义Cell的菜单动作数组

JHMenuAction *action = [[JHMenuAction alloc] init];
action.title = @"标为\n已读";
action.titleColor = [UIColor whiteColor];
action.backgroundColor = JHRGBA(148, 158, 167, 1);
action.actionBlock = ^(JHMenuTableViewCell *cell, NSIndexPath *indexPath){
    JHLog(@"标为已读:%@,row:%d",cell,indexPath.row);
};
self.actions = @[action];

####4、UITableViewCell继承JHMenuTableViewCell并设置相应的Action数组

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    JHMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    if(cell == nil)
    {
        cell
        = [[JHMenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.actions = self.actions;
        
        UILabel *textField = [[UILabel alloc] initWithFrame:CGRectMake(0, 6, 120, 32)];
        textField.tag = 88;
        [cell.customView addSubview:textField];
        cell.customView.layer.borderColor = [UIColor blackColor].CGColor;
        cell.customView.layer.borderWidth = 0.5;
    }
    
    //此步骤可针对不同的cell修改JHAction
    //使用时请注意,防止JHAction错乱
    if(indexPath.row % 2 == 0)
    {
        cell.actions = self.actions1;
    }
    else
    {
        cell.actions = self.actions;
    }
    UILabel *label = (UILabel *)[cell.customView viewWithTag:88];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = [NSString stringWithFormat:@"%d",indexPath.row];
    return cell;
}
##配置JHMenuTableView参数 ####在JHMicro.h文件中配置JHMenuTableView参数
/**
 *  JHActionButton的宽度
 */
extern const NSInteger      JHActionButtonWidth;

/**
 *  JHActionButton文本的字体
 */
extern const NSInteger      JHActionButtonTextFontSize;

/**
 *  展开Menu时,是否显示更多按钮
 */
extern const BOOL           JHActionMoreButtonShow;

/**
 *  更多按钮出现的index,从右向左,从0开始
 */
extern const NSInteger      JHActionMoreButtonIndex;

/**
 *  Menu展开/收缩的动画持续时间,单位为秒
 */
extern const float          JHMenuExpandAnimationDuration;
##效果图 ![](https://github.com/Jiahai/JHMenuTableViewDemo/blob/master/SnapShot/JHMenuTableViewDemo.gif)

jhmenutableviewdemo's People

Contributors

jiahai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.