开发者

How to change UISearchBar width

开发者 https://www.devze.com 2023-03-17 07:28 出处:网络
I added UISearchBar to view using interface builder. Than i changed its width to be smaller using UI builder too and put it in the middle of the view. When i s开发者_C百科tart application, my search b

I added UISearchBar to view using interface builder. Than i changed its width to be smaller using UI builder too and put it in the middle of the view. When i s开发者_C百科tart application, my search bar looks correctly with width and location i defined. However after the first touch inside of it, it gets to its normal state with default width. Only its start position stays like it was defined so that it ends after the bounds of the screen.

I guess i have to subclass it and maybe override some drawRect method but i have no idea how to do it and i could not find solution to this in the net.


Try with this code

searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 10, 44)];


Same problem happened to me, and I found that it was the container view that holds the UISearchBar should have the width that i need

0

精彩评论

暂无评论...
验证码 换一张
取 消