• <bdo id='lxITr'></bdo><ul id='lxITr'></ul>

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

    <small id='lxITr'></small><noframes id='lxITr'>

  • <legend id='lxITr'><style id='lxITr'><dir id='lxITr'><q id='lxITr'></q></dir></style></legend>

      1. 如何缩放 UIButton 的 imageView?

        How do I scale a UIButton#39;s imageView?(如何缩放 UIButton 的 imageView?)
      2. <tfoot id='Wnzxb'></tfoot>

            <small id='Wnzxb'></small><noframes id='Wnzxb'>

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

                  <tbody id='Wnzxb'></tbody>
                <legend id='Wnzxb'><style id='Wnzxb'><dir id='Wnzxb'><q id='Wnzxb'></q></dir></style></legend>

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

                  问题描述

                  我使用 [UIButton setImage:forState:] 创建了一个名为button"的 UIButton 实例,其中包含一个图像.button.frame 大于图片尺寸.

                  I created a UIButton instance named "button" with an image using [UIButton setImage:forState:]. The button.frame is larger than the image's size.

                  现在我想缩小这个按钮的图像.我尝试更改button.imageView.framebutton.imageView.boundsbutton.imageView.contentMode,但似乎都无效.

                  Now I want to scale this button's image smaller. I tried changing button.imageView.frame, button.imageView.bounds and button.imageView.contentMode, but all seem ineffective.

                  谁能帮我缩放 UIButton 的 imageView?

                  Can anyone help me scale a UIButton's imageView?

                  我像这样创建了 UIButton:

                  UIButton *button = [[UIButton alloc] init];
                  [button setImage:image forState:UIControlStateNormal];
                  

                  我尝试像这样缩放图像:

                  I tried to scale the image like this:

                  button.imageView.contentMode = UIViewContentModeScaleAspectFit;
                  button.imageView.bounds = CGRectMake(0, 0, 70, 70);
                  

                  还有这个:

                  button.imageView.contentMode = UIViewContentModeScaleAspectFit;
                  button.imageView.frame = CGRectMake(0, 0, 70, 70);
                  

                  推荐答案

                  对于原发帖者,这是我找到的解决方案:

                  For the original poster, here is the solution I found:

                  commentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
                  

                  这将允许您的按钮水平缩放.还有一个垂直设置.

                  This will allow your button to scale horizontally. There is a vertical setting as well.

                  我花了几个小时才弄明白(该属性的命名非常不直观),所以我想分享一下.

                  Took me several hours to figure that one out (the naming of the property is very unintuitive) so figured I'd share.

                  这篇关于如何缩放 UIButton 的 imageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  UIButton title text color(UIButton 标题文本颜色)
                  Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                  Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                  How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                  iPhone UIButton - image position(iPhone UIButton - 图像位置)
                  UIButton remove all target-actions(UIButton 删除所有目标动作)
                  • <i id='uM6Bt'><tr id='uM6Bt'><dt id='uM6Bt'><q id='uM6Bt'><span id='uM6Bt'><b id='uM6Bt'><form id='uM6Bt'><ins id='uM6Bt'></ins><ul id='uM6Bt'></ul><sub id='uM6Bt'></sub></form><legend id='uM6Bt'></legend><bdo id='uM6Bt'><pre id='uM6Bt'><center id='uM6Bt'></center></pre></bdo></b><th id='uM6Bt'></th></span></q></dt></tr></i><div id='uM6Bt'><tfoot id='uM6Bt'></tfoot><dl id='uM6Bt'><fieldset id='uM6Bt'></fieldset></dl></div>
                  • <small id='uM6Bt'></small><noframes id='uM6Bt'>

                      <bdo id='uM6Bt'></bdo><ul id='uM6Bt'></ul>

                        <tbody id='uM6Bt'></tbody>

                            <tfoot id='uM6Bt'></tfoot>
                            <legend id='uM6Bt'><style id='uM6Bt'><dir id='uM6Bt'><q id='uM6Bt'></q></dir></style></legend>