I have my own subclass of UIButton . I add a UIImageView to it and add an image. I would like to draw it on top of the image with a tint of color, but this does not work.
So far I have:
- (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]; ...
and to choose from:
- (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 have I done wrong? (The color of the image always remains the same.)
ios xcode uibutton uiimageview tintcolor
Marko Zadravec Mar 04 '14 at 11:27 2014-03-04 11:27
source share