Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emojis in Segmented Control [closed]

I have emojis used in the different segments for my Segmented Control. When I select a segment, the selected segment highlights (indicates which one was selected), and the emoji suddenly becomes all white. Is there anyway to fix this issue? Thanks!

like image 983
Josh D. Avatar asked Feb 07 '23 15:02

Josh D.


1 Answers

I use follow code and it worked for me.

enter image description here

OC:

[segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateSelected];

Swift:

let segmentedControl = UISegmentedControl(items: ["๐Ÿ˜Š","๐Ÿ˜ข","moon"])
segmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.whiteColor()], forState:.Selected)
like image 54