<legend id='96pHb'><style id='96pHb'><dir id='96pHb'><q id='96pHb'></q></dir></style></legend>

  1. <small id='96pHb'></small><noframes id='96pHb'>

    • <bdo id='96pHb'></bdo><ul id='96pHb'></ul>

    <tfoot id='96pHb'></tfoot>

      <i id='96pHb'><tr id='96pHb'><dt id='96pHb'><q id='96pHb'><span id='96pHb'><b id='96pHb'><form id='96pHb'><ins id='96pHb'></ins><ul id='96pHb'></ul><sub id='96pHb'></sub></form><legend id='96pHb'></legend><bdo id='96pHb'><pre id='96pHb'><center id='96pHb'></center></pre></bdo></b><th id='96pHb'></th></span></q></dt></tr></i><div id='96pHb'><tfoot id='96pHb'></tfoot><dl id='96pHb'><fieldset id='96pHb'></fieldset></dl></div>

      Swift UIImageView 拉伸方面

      Swift UIImageView Stretched Aspect(Swift UIImageView 拉伸方面)
      <legend id='SXmbi'><style id='SXmbi'><dir id='SXmbi'><q id='SXmbi'></q></dir></style></legend>
      • <bdo id='SXmbi'></bdo><ul id='SXmbi'></ul>

        • <i id='SXmbi'><tr id='SXmbi'><dt id='SXmbi'><q id='SXmbi'><span id='SXmbi'><b id='SXmbi'><form id='SXmbi'><ins id='SXmbi'></ins><ul id='SXmbi'></ul><sub id='SXmbi'></sub></form><legend id='SXmbi'></legend><bdo id='SXmbi'><pre id='SXmbi'><center id='SXmbi'></center></pre></bdo></b><th id='SXmbi'></th></span></q></dt></tr></i><div id='SXmbi'><tfoot id='SXmbi'></tfoot><dl id='SXmbi'><fieldset id='SXmbi'></fieldset></dl></div>
        • <tfoot id='SXmbi'></tfoot>

            <tbody id='SXmbi'></tbody>

            • <small id='SXmbi'></small><noframes id='SXmbi'>

                本文介绍了Swift UIImageView 拉伸方面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                UIImageView 不正确地呈现图像的大小.使用 Scale Aspect Fit,如果 UIImageView 是正方形,则图像的宽高比正确,图像未填充的区域具有透明度.

                UIImageView renders the size of an image incorrectly. Using Scale Aspect Fit, if the UIImageView is a square the image is the correct aspect ratio with transparency in the areas the image does not fill.

                //Image is Square & Correct Size
                var imageView = UIImageView(frame: CGRectMake(0, 50, 320, 320))
                imageView.clipsToBounds = true
                imageView.contentMode = UIViewContentMode.ScaleAspectFit
                
                //Image is Rectangle & Incorrect Size
                var imageView = UIImageView(frame: CGRectMake(0, 50, 320, 450))
                imageView.clipsToBounds = true
                imageView.contentMode = UIViewContentMode.ScaleAspectFit
                

                UIImageView 需要在屏幕的顶部和底部触摸边缘并有透明空间,并且内部的图像需要保持其原始比例而不是拉伸更高.我附上了两张图片,说明 UIImageView 内的图像是如何呈现的.

                The UIImageView needs to touch the edges and have transparent space at the top and bottom of the screen and the image inside needs to keep its original ratio rather than stretching taller. I have attached two images of how the image inside the UIImageView is rendering.

                推荐答案

                我向 UIImageView 添加了一个自动调整大小的蒙版,它现在显示正确的比例.

                I added an autoresizing mask to the UIImageView and it now displays the correct ratios.

                imageView.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth
                imageView.contentMode = UIViewContentMode.ScaleAspectFit
                

                这个答案帮助了我:使用 AVCaptureSession sessionPreset = 拉伸捕获的照片AVCaptureSessionPresetPhoto 因为我使用的是通过手机相机拍摄的图像.

                This answer helped me: Captured photo is stretched with AVCaptureSession sessionPreset = AVCaptureSessionPresetPhoto as I was using an image that was taken through the phones camera.

                这篇关于Swift UIImageView 拉伸方面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                Difference between retain and copy?(保留和复制的区别?)
                Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                How to copy a quot;Dictionaryquot; in Swift?(如何复制“字典在斯威夫特?)
                Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                What is the difference between quot;copyquot; and quot;retainquot;?(“复制和“复制有什么区别?和“保留?)

                  <tbody id='p5UUq'></tbody>
                <tfoot id='p5UUq'></tfoot>
                <legend id='p5UUq'><style id='p5UUq'><dir id='p5UUq'><q id='p5UUq'></q></dir></style></legend>

              1. <small id='p5UUq'></small><noframes id='p5UUq'>

                  1. <i id='p5UUq'><tr id='p5UUq'><dt id='p5UUq'><q id='p5UUq'><span id='p5UUq'><b id='p5UUq'><form id='p5UUq'><ins id='p5UUq'></ins><ul id='p5UUq'></ul><sub id='p5UUq'></sub></form><legend id='p5UUq'></legend><bdo id='p5UUq'><pre id='p5UUq'><center id='p5UUq'></center></pre></bdo></b><th id='p5UUq'></th></span></q></dt></tr></i><div id='p5UUq'><tfoot id='p5UUq'></tfoot><dl id='p5UUq'><fieldset id='p5UUq'></fieldset></dl></div>
                    • <bdo id='p5UUq'></bdo><ul id='p5UUq'></ul>