Giter VIP home page Giter VIP logo

actionsheetlikewechat's Introduction

ActionSheetLikeWeChat

高度自定义的ActionSheet(类似微信)

###效果图 ![JM_ActionSheet](https://github.com/ZJM6658/ActionSheetLikeWeChat/blob/master/showgif/ActionSheet.gif?raw=true" alt="ActionSheet.gif">)

###如何引用 1、将JM_ActionSheet文件夹拖入你的工程中

2、使用CocoaPods

	pod 'JM_ActionSheet'

###代码原理 1、JM_ActionSheet继承于UIView,它根据M_SheetItem来显示每一行的样式:

	//每一行的样式Model(字体颜色、字号、行高有默认值,也可以自定义)
	@interface M_SheetItem : NSObject

	@property(nonatomic, strong) NSString *title;       //标题
	@property(nonatomic, strong) UIColor *textColor;    //字体颜色 default is blackColor;
	@property(nonatomic, strong) UIFont *textFont;      //字号 default is 15;
	@property(nonatomic) CGFloat height;                //行高 default is 44;
	@property(nonatomic) BOOL isTitle;                  //标题无法点击 default is NO;

	- (instancetype)initWithTitle:(NSString *)title;
	@end

2、需要调用JM_ActionSheet的类需要遵循JM_ActionSheetDelegate,并实现点击处理方法

	@protocol JM_ActionSheetDelegate <NSObject>

	- (void)jm_actionSheet:(JM_ActionSheet *)jm_actionSheet clickedItem:(M_SheetItem *)item atIndex:(NSIndexPath *)indexPath;   //item点击事件

	@end

###使用方法 1、导入头文件

	#import "JM_ActionSheet.h"

2、调用方法

	//构造数据源
	M_SheetItem *titleitem = [[M_SheetItem alloc] initWithTitle:@"删除后将无法恢复,确定要删除吗?"];
	titleitem.textFont = [UIFont systemFontOfSize:12];
	titleitem.textColor = [UIColor grayColor];
	titleitem.height = 40;
	titleitem.isTitle = YES; //标题item

	M_SheetItem *item0 = [[M_SheetItem alloc] initWithTitle:@"删除好友"];
	item0.textFont = [UIFont systemFontOfSize:14];
	item0.textColor = [UIColor orangeColor];
	item0.height = 50;

	M_SheetItem *item1 = [[M_SheetItem alloc] initWithTitle:@"取消"];
	item1.textColor = [UIColor redColor];
    
    //初始化对象+组装数据源
    NSArray *dataArray = @[@[titleitem, item0],@[item1]];
    JM_ActionSheet *sheet = [[JM_ActionSheet alloc] initWithDelegate:self];
    [sheet setDataSource:dataArray];  //数据源, 外层数组为组数,内层数组为每组行数 ex:@[@[@"xx",@"zz", ...],@[@"yy",...],...]
    [sheet show];

3、具体使用可下载Demo查看。

actionsheetlikewechat's People

Contributors

zjm6658 avatar

Stargazers

 avatar  avatar  avatar LuckyRoc avatar soft_knife avatar  avatar Yakun Wang avatar

Watchers

James Cloos avatar  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.