ios - UISegmentedControl messed up after customization -


so after customize uisegmentedcontrol, got messed up, label got shifted , there white vertical line don't know came from. divider got off-center, have checked black line @ 40-41px of 80px image, must centered. want doing wrong or have experience before?

before customization: enter image description here

after customization:

note: divider images horizontal flip of each other.

enter image description here

enter image description here

code:

uiimage *un_sel = [uiimage imagenamed:@"divider-un-sel"]; uiimage *sel_un = [uiimage imagenamed:@"divider-sel-un"];  [_segmentcontrol setdividerimage:un_sel forleftsegmentstate:uicontrolstatenormal rightsegmentstate:uicontrolstateselected barmetrics:uibarmetricsdefault];  [_segmentcontrol setdividerimage:sel_un forleftsegmentstate:uicontrolstateselected rightsegmentstate:uicontrolstatenormal barmetrics:uibarmetricsdefault];  uiimage *normal = [[uiimage imagenamed:@"segment-normal"] stretchableimagewithleftcapwidth:20 topcapheight:0]; uiimage *selected = [[uiimage imagenamed:@"segment-selected"] stretchableimagewithleftcapwidth:20 topcapheight:0];  [_segmentcontrol setbackgroundimage:normal forstate:uicontrolstatenormal barmetrics:uibarmetricsdefault]; [_segmentcontrol setbackgroundimage:selected forstate:uicontrolstateselected barmetrics:uibarmetricsdefault]; 

solved problem using

[[uiimage imagenamed:@"segment-normal"]  resizableimagewithcapinsets:uiedgeinsetsmake(0, 15, 0, 15)]; 

instead of stretchableimagewithleftcapwith:topcapheight


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -