UIImage方面合身和对齐到顶部 [英] UIImage aspect fit and align to top

查看:384
本文介绍了UIImage方面合身和对齐到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,方向拟合会将图像对齐到帧的底部。是否有方法可以覆盖 对齐,同时保持方向适合 c>完整?

It looks like aspect fit aligns the image to the bottom of the frame by default. Is there a way to override the alignment while keeping aspect fit intact?

推荐答案

简而言之,您不能使用 UIImageView 执行此操作。

In short, you cannot do this with a UIImageView.

一个解决方案是对包含 UIImageView UIView >并根据图像大小更改其帧。例如,您可以在此处找到一个版本。

One solution is to subclass a UIView containing an UIImageView and change its frame according to image size. For example, you can find one version here.

这篇关于UIImage方面合身和对齐到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆