I was looking for a solution to add an UIImage
to my UIButton
. The problem was just it displays the image bigger than needed. Just helped me with this:
_imageViewBackground = [[UIImageView alloc] initWithFrame:rectImageView];
_imageViewBackground.image = [UIImage imageNamed:@"gradientBackgroundPlain"];
[self addSubview:_imageViewBackground];
[self insertSubview:_imageViewBackground belowSubview:self.label];
_imageViewBackground.hidden = YES;
Every time I want to display my UIImageView
I just set the var hidden
to YES
or NO
.
There might be other solutions but I got confused so many times with this stuff and this solved it and I didn't need to deal with internal stuff UIButton
is doing in background.