如何在UISegmentedControl

时间:2016-05-19 15:14:21

标签: cocoa-touch uisegmentedcontrol emoji

如果我想将表情符号放入我的分段控件中,我可能希望在第一行获得图像,但获得第二和第三。

enter image description here

我该如何解决?

1 个答案:

答案 0 :(得分:2)

只需将@{NSForegroundColorAttributeName : [UIColor whiteColor]}作为UIControlStateSelected状态的文本属性

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UISegmentedControl *segmentedControl;

@end

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

    NSDictionary *dict = @{NSForegroundColorAttributeName : [UIColor whiteColor]};


    [self.segmentedControl setTitleTextAttributes:dict forState:UIControlStateSelected];
}

@end