1

In plain words, what does this statement do :

[self.searchBar setBackgroundImage:[UIImage imageWithCGImage:self.searchBar.backgroundImage.CGImage]];

The reason why I am asking this is because I have the following problem. I have a search bar linked to an asset which is drawing weirdly when I startEditing it. Here's why -

the SearchBar's height is [44] normally and [88] with the options. The two image assets are of the same size. On editing, the search bar is rendered as :

 ____________________________________________
| 88 Image|88 Image|88 Image|88 Image|.......|        
|_________|________|________|________|_______|
| 88 Image|88 Image|88 Image|88 Image|.......|        
|_________|________|________|________|_______|
|               the [88] Image               |
|                                            |
|                                            |
|____________________________________________|

Each line is of 11 pts. The image is in pixels. I'm assuming this has something to do with Quartz. The above behavior causes an ugly black line to appear in the top box, where the search bar is, as in : enter image description here

I tried changing the asset's sizing. Added vertical / horizontal slicing/ stretching but they either change the look to something uglier or add "stretchmarks" to the view.

And I have no Idea why. But when I set the background Image as I do above, I get the correct way to do it :

 ____________________________________________
| 88 Image|88 Image|88 Image|88 Image|.......|        
|         |        |        |        |       |
|         |        |        |        |       |
|_________|________|________|________|_______|
|               the [88] Image               |
|                                            |
|                                            |
|____________________________________________|

Can someone explain to me why this is happening? Is this a good fix? Is there something better?

gran_profaci
  • 8,087
  • 15
  • 66
  • 99

0 Answers0