ios - UISegmentedControl titletext is blurry -
i have implemented header view in collection view. uisegmentedcontroll 3 items.
here code:
nsarray *itemarray = [nsarray arraywithobjects: @"following", @"everybody", @"nearby", nil]; uisegmentedcontrol *segmentedcontrol = [[uisegmentedcontrol alloc] initwithitems:itemarray]; uifont *font = [uifont fontwithname:@"patuaone-regular" size:12.0f]; uicolor *notchosenbuttoncolor = [uicolor colorwithred:(201.0/255.0f) green:(198.0/255.0f) blue:(191.0/255.0f) alpha:1.0]; uicolor *chosenbuttoncolor = [uicolor colorwithred:(235.0/255.0f) green:(218.0/255.0f) blue:(102.0/255.0f) alpha:1.0]; nsdictionary *normalattributes = [nsdictionary dictionarywithobjectsandkeys: font, uitextattributefont, notchosenbuttoncolor, uitextattributetextcolor, nil]; nsdictionary *selectedattributes = [nsdictionary dictionarywithobjectsandkeys: font, uitextattributefont, chosenbuttoncolor, uitextattributetextcolor, nil]; [segmentedcontrol settitletextattributes:normalattributes forstate:uicontrolstatenormal]; [segmentedcontrol settitletextattributes:selectedattributes forstate:uicontrolstateselected]; [segmentedcontrol setbackgroundimage:[uiimage imagenamed:@"greenbt_bg.png"] forstate:uicontrolstatenormal barmetrics:uibarmetricsdefault]; [segmentedcontrol setbackgroundimage:[uiimage imagenamed:@"standard_bt_h"] forstate:uicontrolstateselected barmetrics:uibarmetricsdefault]; [segmentedcontrol setbackgroundcolor:[uicolor clearcolor] ]; segmentedcontrol.frame = cgrectmake(5, 20, 280, 25); segmentedcontrol.segmentedcontrolstyle = uisegmentedcontrolstyleplain; segmentedcontrol.selectedsegmentindex = 0; [segmentedcontrol setdividerimage:[uiimage imagenamed:@"separator.png"] forleftsegmentstate:uicontrolstatenormal rightsegmentstate:uicontrolstatenormal barmetrics:uibarmetricsdefault]; [headerview addsubview:segmentedcontrol];
the segmentedcontrol looks this:
why text of segments blurry when not selected?
edit
solved it! added [uicolor clearcolor], uitextattributetextshadowcolor
normalattributes
that caused default shadowcolor.
try set uitextattributetextshadowcolor
, uitextattributetextshadowoffset
in titletextattributes.
you might have experiment best visual appearance. can set shadowcolor attribute [uicolor clearcolor]
.
Comments
Post a Comment