一、GMZoomImageView具有放大和保存图片的功能。
使用方式
1.导入头文件GMZoomImageView.h
2.将UIImageView替换GMZoomImageView即可
在GMZoomImageView.h暴露了移除手势和添加手势的入口。
- (void)addTapGesture;//添加点击手势
- (void)removeTapGesture;//移除点击手势
//- (void)addLongGesture;//添加长按手势
//
//- (void)removeLongGestrue;//移除长按手势
保存图片成功或失败的弹窗提醒,处理了控制器上添加了view视图,造成弹出的弹窗被view遮挡。
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:action];
UIView *backView = [[UIApplication sharedApplication].keyWindow viewWithTag:101];
if (backView) {
//处理放大图片后,无法模态弹出UIAlertController的解决方式
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
window.tag = 102;
window.userInteractionEnabled = NO;
window.backgroundColor = [UIColor clearColor];
UIViewController *rootVC = [[UIViewController alloc] init];
rootVC.view.backgroundColor = [UIColor clearColor];
window.windowLevel = UIWindowLevelAlert + 1;
[window makeKeyAndVisible];
window.rootViewController = rootVC;
[backView addSubview:window];
[rootVC presentViewController:alertVC animated:YES completion:nil];
} else {
UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
[vc presentViewController:alertVC animated:YES completion:nil];
}
二、另外:自定义的CustomSheet底部弹窗,类似微信,参考http://www.devashen.com/blog/2016/01/22/assheet/
根据不同枚举类型,弹窗样式不一样。
typedef NS_ENUM(NSInteger, CustomSheetType) {//提示框类型
CustomSheetTypeDefault, //默认 标示没有红字
CustomSheetTypePrompt, //title 标示有标题
CustomSheetTypeWarn, //title 警告标识(红色字体) 显示红字(比如"删除"显示红色)
};
使用方式:
CustomSheet *sheet = [[CustomSheet alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) titleArr:@[@"保存图片"] sheetType:CustomSheetTypeDefault];
__weak typeof(sheet) weakSheet = sheet;
sheet.Click = ^(NSInteger clickIndex) {
switch (clickIndex) {
case 0:
//TODO
break;
default:
break;
}
[weakSheet hiddenSheet:^(BOOL isHidden) {
}];
};
[[UIApplication sharedApplication].keyWindow addSubview:sheet];
}
网友评论