<bdo id='TkdQb'></bdo><ul id='TkdQb'></ul>
    <legend id='TkdQb'><style id='TkdQb'><dir id='TkdQb'><q id='TkdQb'></q></dir></style></legend>

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

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

      如何使用 imageEdgeInsets 更改 UIButton 中图像的 tintColor?

      How to change tintColor of image in UIButton with imageEdgeInsets?(如何使用 imageEdgeInsets 更改 UIButton 中图像的 tintColor?)

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

          <tfoot id='AwGUO'></tfoot>

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

            <legend id='AwGUO'><style id='AwGUO'><dir id='AwGUO'><q id='AwGUO'></q></dir></style></legend>

                  <tbody id='AwGUO'></tbody>
                本文介绍了如何使用 imageEdgeInsets 更改 UIButton 中图像的 tintColor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的 Objective-c 应用程序中有一个 UIButton.我的按钮已修改,添加了如下文本和图像:

                I I have an UIButton in my objective-c application. My button was modified adding text and image like:

                - (void)centerButtonAndImageWithSpacing:(CGFloat)spacing {
                     CGFloat insetAmount = spacing / 2.0;
                     self.imageEdgeInsets = UIEdgeInsetsMake(0, -insetAmount, 0, insetAmount);
                     self.titleEdgeInsets = UIEdgeInsetsMake(0, insetAmount, 0, -insetAmount);
                     self.contentEdgeInsets = UIEdgeInsetsMake(0, insetAmount, 0, insetAmount);
                }
                

                然后我用这段代码添加图像:

                And then I add the image with this code:

                [self.myButton setImage:[UIImage imageNamed:@"imageButton.png"] forState:UIControlStateNormal];
                

                我想更改图像的 tintColor,但是当我尝试更改时,我的代码不起作用:

                I want change the tintColor of the image, but when I try change this, my code isn't work:

                [self.myButton setTintColor:[UIColor redColor]];
                

                我正在尝试使用此代码,但没有成功:

                I'm trying use this code, but didn't work:

                UIImage* img = [UIImage imageNamed:imageName];
                icon.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
                icon.tintColor = [UIColor redColor];
                

                我有这个:

                我想得到它:

                如何更改 imageButton 的颜色?

                How could I change the color of the imageButton?

                推荐答案

                我们可以通过以下方式为透明图标应用所需的颜色.

                We can apply the desired color for the transparent icons with the following way.

                1.将图像拖到 Assets.xcassets 并在资产属性检查器中将 Render as 属性更改为 Template Image.

                1.Drag the image on Assets.xcassets and In asset attribute inspector change the Render as attribute to Template Image.

                2.并像下面这样设置所需的色调颜色.

                2.And set the required tint color like below way.

                icon.tintColor = [UIColor redColor];
                

                希望对你有所帮助.

                这篇关于如何使用 imageEdgeInsets 更改 UIButton 中图像的 tintColor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 删除所有目标动作)

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

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

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