swift 点击图片预览,有放大缩小动画

本文介绍了如何在Swift中实现图片点击后弹出预览窗口,并且包含平滑的放大和缩小动画效果,为用户提供更好的视觉体验。
摘要由CSDN通过智能技术生成
//Cell的点击事件
let rect = targetCell.convert(targetCell.chatImageView.frame, to: self.listTableView)
let rect2 = self.listTableView.convert(rect, to: self.view)
                
//获取状态栏的rect
let statusRect = UIApplication.shared.statusBarFrame
//获取导航栏的rect
let navRect = self.navigationController?.navigationBar.frame
let navBarHeight = statusRect.height + (navRect?.height)!
                
let tapFrame = CGRect.init(x: rect2.origin.x, y: rect2.origin.y + navBarHeight, width: rect2.width, height: rect2.height)
let image = targetCell.chatImageView.image
showZoomImageView(image, tapFrame:tapFrame)

//图片缩放动画
func showZoomImageView(image:UIImage, tapFrame:CGRect) {
        let bgView = UIScrollView.init(frame: UIScreen.main.bounds)
        bgView.backgroundColor = UIColor.clear
        let tapBg = UITapGestureRecognizer.init(target: self, action: #selector(tapBgView(tapBgRecognizer:)))
        bgView.addGestureRecognizer(ta
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值