ios - 使用UIViewContentModeScaleAspectFit图片变模糊。如何解决这个问题呢?
伊谢尔伦
伊谢尔伦 2017-04-17 15:36:00
[iOS讨论组]

如题。

图片大小不固定。但是我想让图片在容器里面保持原本的尺寸,正常显示。

------补充------

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
PHP中文网

如要使用原尺寸
使用下面的

    UIViewContentModeCenter,
    UIViewContentModeTop,
    UIViewContentModeBottom,
    UIViewContentModeLeft,
    UIViewContentModeRight,
    UIViewContentModeTopLeft,
    UIViewContentModeTopRight,
    UIViewContentModeBottomLeft,
    UIViewContentModeBottomRight,

选择UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit,UIViewContentModeScaleAspectFill
如果容器frameUIImage的尺寸不合,
都会进行不同形式的拉伸

下面是效果,用的UIViewContentModeCenter

//所有代码
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bbbbb"]];
imageView.frame = self.view.frame;
imageView.contentMode = UIViewContentModeCenter;
[self.view addSubview:imageView];


没问题啊

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号