UISegmentedControl with Image and Title

后端 未结 6 2240
滥情空心
滥情空心 2020-12-15 13:45

I am using a UISegmentedControl inside a UIToolBar as button. I can\'t use a normal UIButtonBarItem, because I need to set the t

6条回答
  •  被撕碎了的回忆
    2020-12-15 14:41

    try this:

    UISegmentedControl* searchButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"", nil]];
    [searchButton insertSegmentWithImage:[UIImage imageNamed:@"up_button.png"] atIndex:0 animated:YES];
    [searchButton insertSegmentWithImage:[UIImage imageNamed:@"down_button.png"] atIndex:1 animated:YES];
    searchButton.segmentedControlStyle = UISegmentedControlStyleBar;
    searchButton.tintColor = [UIColor colorWithRed:0.27 green:0.60 blue:0.20 alpha:1.00];
    [searchButton setMomentary:YES];
    

提交回复
热议问题