【iOS】JTSActionSheet的改进

       今天在碰到需要在UISheetView的选择按钮上添加左侧小图标,一番折腾发现本身是不支持的!没办法只能想办法自定义,老规矩,先上网查找先辈们的经验,避免重复造轮。一番搜索,发现JTSActionSheet还是很棒的,具体我就不啰嗦了,可以看:https://github.com/jaredsinclair/JTSActionSheet;

       但是JTSActionSheet还是不支持添加小图标的,并且是支持ios7以上的,于是我自己修改了下,最后实现了小图标功能,并且也在ios6.1下运行成功了,具体效果图如下:

                       

具体修改如下:

                                   

还有在buttonView里面的修改:

使用例子:

 

- (void)showShareSheet
{
    JTSActionSheetTheme *theme = [JTSActionSheetTheme defaultTheme];
    JTSActionSheetItem *wechat = [JTSActionSheetItem itemWithTitle:NSLocalizedString(@"Wechat", nil) image:[UIImage imageNamed:@"Wechat"] action:^{
        // do stuff
        [PBSocietyShare defaultManager].type = PBSocietyShareTypeWXSomeone;
        if ([[PBSocietyShare defaultManager] canShare]) {
            UIImage *image = [self jietu];
            [PBSocietyShare defaultManager].shareImage = image;
            [[PBSocietyShare defaultManager] share];
        }
    } isDestructive:NO];
    
    JTSActionSheetItem *mail = [JTSActionSheetItem itemWithTitle:NSLocalizedString(@"Mail", nil) image:[UIImage imageNamed:@"Mail"] action:^{
        // do stuff
        [PBSocietyShare defaultManager].type = PBSocietyShareTypeEmail;
        if ([[PBSocietyShare defaultManager] canShare]) {
            UIImage *image = [self jietu];
            [PBSocietyShare defaultManager].shareImage = image;
            [[PBSocietyShare defaultManager] share];
            //[self presentModalViewController:[PBSocietyShare defaultManager].mc animated:YES];
            [self presentViewController:[PBSocietyShare defaultManager].mc animated:YES completion:^{
                ;
            }];
        }
    } isDestructive:NO];
    
    JTSActionSheetItem *cancel = [JTSActionSheetItem itemWithTitle:NSLocalizedString(@"Cancel", nil) action:^{
        // respond to cancellation
        // Action blocks can be nil if you want.
    } isDestructive:YES];
    
    JTSActionSheet *sheet = [[JTSActionSheet alloc] initWithTheme:theme  title:NSLocalizedString(@"Share your records to...", nil) actionItems:@[wechat, mail] cancelItem:cancel];
    [sheet showInView:self.view];
}

 

修改过的JTSActionSheet下载地址是:http://download.csdn.net/detail/fengguixian520/8216821
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值