-1

(A) Following line change the image in my imageview.

[(UIImageView *)[cell viewWithTag:400] setImage:[UIImage imageNamed:@"sellsign"]];

(B) Following code change only Title of button. [ I have checked for both UIButton type "System" and "Custom" background image line not working.]

[(UIButton *)[cell viewWithTag:500] setBackgroundImage:[UIImage imageNamed:@"sellsign"] forState:UIControlStateNormal];
[(UIButton *)[cell viewWithTag:500] setTitle:@"1" forState:UIControlStateNormal];

(C) Button Configuration

enter image description here

Button tittle gets change to 1 but there is no change in background image.

Fact 1: I am referring correct button as button title change to 1
Fact 2: Button state is also normal as I can see button title 1
Fact 3: I am referring correct image name as it set in Imageview

Any idea that why only UIButton Background image has this strange behaviour. I think I am missing something in latest iOS.

How can I set my desire image in UIButton as a background image?

Note: Some one close the question by saying it's duplicate and provided following link,
UIButton image behavior changed in iOS 15?

This is not the solution. It says change the button style. It's patch to achieve output. On that link it's mention that it's old way and one need to adopt new way. Apple introduce new way so there must be solution for it as well.

Parth
  • 19
  • 4

1 Answers1

0

You need to set the Background Configuration for Background field as Custom also.

susanna
  • 11
  • 5