IOS 悬浮在页面上的半透明提示框(JGActionSheetSection)

有时候我们想做一个,类似于UIActionSheet的东西,而UIActionSheet又不能满足我们,那么我们就可以用JGActionSheet来实现。

 

JGActionSheetSection的下载URL:

http://code4app.com/ios/JGActionSheet/53f31014933bf02c718b550b

 

要使用JGActionSheet就要引用JGActionSheet.h文件

 

JGActionSheetSection的思路是:

sheet,是全部的框体,一个sheet里面,包含很多个section,每个section下呢,又包含很多button,所以当用sheet.sections取值的时候,实际上取出的是一个数组,section.buttons也是同理。

 

代码:

//初始化一个section

//初始化的section的title是section title,在标题底下的方位会显示message,内容是message under title,buttonTitles参数是一个数组参数,里面是这个section里面的button的名字,buttonStyle参数是button的样式,这个样式也可以自己定义

JGActionSheetSection *section = [JGActionSheetSection sectionWithTitle:@"section title" message:@"message under title" buttonTitles:@[@"button1",@"button2"] buttonStyle:JGActionSheetButtonStyleDefault];

 

//初始化sheet,需要传入一开始初始化的section,是一个数组参数

JGActionSheet *sheet = [JGActionSheetactionSheetWithSections:@[section]];

//设置dletegate

sheet.delegate = self;

//sheet悬停的设置

 

sheet.insets = UIEdgeInsetsMake(20.0f, 0.0f, 0.0f, 0.0f);

//显示这个sheet

[sheet showInView:self.XXXXXXX.viewanimated:YES];

//点击里面任意button的回调事件

[sheet setButtonPressedBlock:^(JGActionSheet *sheet, NSIndexPath *indexPath) {

    //取得点击的button在哪个section(indexPath.section是section的下标)

    JGActionSheetSection *JGS = (JGActionSheetSection *)sheet.sections[indexPath.section];

    //取得点击的那个button(indexPath.row是section里面button的下标)

    UIButton *btn = JGS.buttons[indexPath.row];

    //关闭悬浮框

    [sheet dismissAnimated:YES];

 

    XXXXXXXXXXXXX;

}

                                                                                                    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值