今天在碰到需要在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