【问题标题】:How to set images to a UISearchBar's scope bar items?如何将图像设置为 UISearchBar 的范围栏项目?
【发布时间】:2013-12-17 17:31:39
【问题描述】:

对于UISearchBar 的范围栏,我想设置图像而不是标题来标识不同的范围。我发现只有scopeButtonTitles 方法在UISearchBar 类引用中设置标题。有没有办法为范围设置图像?

【问题讨论】:

    标签: ios objective-c ios7 uikit uisearchbar


    【解决方案1】:

    很简单:

    // use Appearance proxy:
    id temp = [UISegmentedControl appearanceWhenContainedIn:[UISearchBar class], nil];
    
    UIImage * img = [UIImage imageNamed:@"my_img1"];
    [temp setImage:img forSegmentAtIndex: 0];
    
    img = [UIImage imageNamed:@"my_img2"];
    [temp setImage:img forSegmentAtIndex: 1];
    
    .....
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-31
      • 2013-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多