iOS实现点击微信头像(放大、缩放、保存)效果

2020-01-18 21:13:42于丽

最后一个就是长按弹出菜单(UIAlertController)了:


- (void)longPress:(UILongPressGestureRecognizer *)recognizer {
 
 // 为了避免弹警告:Warning: Attempt to present on which is already presenting ,最好加入状态判断
 if (recognizer.state == UIGestureRecognizerStateBegan) {
 UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"QuoraDots" message:nilpreferredStyle:UIAlertControllerStyleActionSheet];
 
 [alertControlleraddAction:[UIAlertActionactionWithTitle:@"保存" style:UIAlertActionStyleDefaulthandler:nil]];
 [alertControlleraddAction:[UIAlertActionactionWithTitle:@"取消" style:UIAlertActionStyleCancelhandler:nil]];
 
 UIViewController *vc = self.viewController;
 [vcpresentViewController:alertControlleranimated:YEScompletion:nil];
 }
}

注意一点, longPress: 这个方法会调用很频繁,因此,为了避免 Attempt to present xxx on xxx which is already presenting xxx 这个警告,我们需要判断手势的状态。

源码下载

后话:

这个只是显示单张图片的大图,如果需要显示多张图片类似微信微博的九宫格图片的大图显示,则需要将这个 CYPhotoPreviewer 搞成 UICollectionView 的 item 即可,大家可以尝试尝试。

好了,以上就是这篇文章的全部内容了,希望本文的内容对各位iOS开发者们能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对ASPKU的支持。


注:相关教程知识阅读请移步到IOS开发频道。