单击搜索栏时更改背景图像的位置

时间:2014-06-25 15:02:58

标签: ios background-image uisearchbar

我的搜索栏中有一张背景图片:

 self.searchBar.scopeButtonTitles=nil;
     self.searchBar.showsScopeBar=NO;

     [[UISearchBar appearance] setSearchFieldBackgroundImage:[UIImage imageNamed:@"search-icon-1"]forState:UIControlStateNormal];

     [self.searchBar.layer setBorderWidth:1];
     [self.searchBar.layer setBorderColor:RGB(200,200,200).CGColor];
     self.searchBar.layer.cornerRadius=12;
     [self.searchBar sizeThatFits:CGSizeMake(216, 56)];
     [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setLeftViewMode:UITextFieldViewModeNever];
     [[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
     [[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setFont:opensans2];

默认情况下,当我点击搜索栏时,我的背景图片会移到左侧。

如何在中心更换它? ( - >如何以编程方式访问故事板中存在的变量background offset horizontal?)

0 个答案:

没有答案