如何设置缩放比例以适合宽高比? 迅速

问题描述

我具有以下功能:

private func sizeForImageToDisplay() -> CGSize{
        
        var actualWidth:CGFloat = imageToDisplay!.size.width
        var actualHeight:CGFloat = imageToDisplay!.size.height
        var imgRatio:CGFloat = actualWidth/actualHeight
        let maxRatio:CGFloat = 16/9
        let minRatio:CGFloat = 4/5
        
        if imgRatio > maxRatio {
            print("1")
            imgRatio = frame.size.width / actualWidth
            actualHeight = imgRatio * actualHeight
            actualWidth = frame.size.width
        }
        else if imgRatio < minRatio {
            print("2")
            setZoomScale(scale: CGFloat,animated: Bool)
    
        }
        
        return  CGSize(width: actualWidth,height: actualHeight)
    }

我想,如果imgRatio < minRatio然后将最小缩放比例设置为4:5的宽高比。基本上,这意味着用户的宽高比不能小于4:5,因为您将无法进行足够的缩小。我不知道该怎么做,有人可以帮忙吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...