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

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

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

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

      1. <tfoot id='zbZNg'></tfoot>

        在 UIImageView 上使用 Tint 颜色

        时间:2023-07-09
        1. <legend id='9n1Pd'><style id='9n1Pd'><dir id='9n1Pd'><q id='9n1Pd'></q></dir></style></legend>

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

                <small id='9n1Pd'></small><noframes id='9n1Pd'>

                • 本文介绍了在 UIImageView 上使用 Tint 颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有自己的 UIButton 子类.我在其上添加 UIImageView 并添加图像.我想用浅色在图像上绘制它,但它不起作用.

                  I have my own subclass of UIButton. I add UIImageView on it and add an image. I would like to paint it over the image with a tint color but it doesn't work.

                  到目前为止我有:

                  - (id)initWithFrame:(CGRect)frame
                  {
                      self = [super initWithFrame:frame];
                      if (self) {
                  
                          self.backgroundColor = [UIColor clearColor];
                          self.clipsToBounds = YES;
                  
                          self.circleView = [[UIView alloc]init];
                          self.circleView.backgroundColor = [UIColor whiteColor];
                          self.circleView.layer.borderColor = [[Color getGraySeparatorColor]CGColor];
                          self.circleView.layer.borderWidth = 1;
                          self.circleView.userInteractionEnabled = NO;
                          self.circleView.translatesAutoresizingMaskIntoConstraints = NO;
                          [self addSubview:self.circleView];
                  
                          self.iconView = [[UIImageView alloc]init];
                          [self.iconView setContentMode:UIViewContentModeScaleAspectFit];
                          UIImage * image = [UIImage imageNamed:@"more"];
                          [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
                          self.iconView.image = image;
                          self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
                          [self.circleView addSubview:self.iconView];
                          ...
                  

                  并在选择时:

                  - (void) setSelected:(BOOL)selected
                  {
                      if (selected) {
                          [self.iconView setTintColor:[UIColor redColor]];
                          [self.circleView setTintColor:[UIColor redColor]];
                      }
                      else{
                          [self.iconView setTintColor:[UIColor blueColor]];
                          [self.circleView setTintColor:[UIColor blueColor]];
                      }  
                  }
                  

                  我做错了什么?(图像的颜色始终保持原来的颜色.)

                  What did I do wrong? (The color of the image always stays the same as it was originally.)

                  推荐答案

                  代替这段代码:

                  [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
                  

                  你应该有:

                  image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
                  

                  Swift 4.1

                  image = UIImage(named: "name")!.withRenderingMode(.alwaysTemplate)
                  

                  这篇关于在 UIImageView 上使用 Tint 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何更改 UIButton 标题颜色? 下一篇:为 UIButton 拉伸背景图像

                  相关文章

                    <tfoot id='Qcoh6'></tfoot>
                  1. <legend id='Qcoh6'><style id='Qcoh6'><dir id='Qcoh6'><q id='Qcoh6'></q></dir></style></legend>

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

                    1. <small id='Qcoh6'></small><noframes id='Qcoh6'>