首页 文章

iPhone-如何在圆形按钮的imageView中设置纵向/横向图像

提问于
浏览
1

我必须在圆形按钮中设置图像,图像可以从图库中选取或通过相机捕获 .

现在,当我尝试使用 AspectFit 内容模式在 button.imagview 上设置纵向或横向图像时,图像不会覆盖整个圆形按钮 .

[btnUserPic setImage:userImage forState:UIControlStateNormal];
  btnUserPic.imageView.contentMode = UIViewContentModeScaleAspectFit;

btnUSerPic是 UIButton 对象 .

它看起来像这样 -

肖像图像 -

enter image description here

景观图像 -

enter image description here

如果我试图设置 ConentModeUIViewContentModeScaleAspectFillUIViewContentModeCenter 然后它可以填充圆,但有时图像会变形 .

如何在按钮imageView上设置图像以填充它的整个圆圈?

1 回答

  • 1
    • 它应该是 UIViewContentModeScaleAspectFill 就像你说的那样,但是,选择\捕获图像的选择器可能有问题,请确保使用框架来执行此操作 .

    • 尝试使用相同的图像设置另一个 UIControlStates ,这可能是问题所在 .

    希望我添加一些东西 .

相关问题