Hi there I am using a segmented con开发者_运维知识库trol in my app. I am also setting segmented controls setImage property to set an image for each segment of the control. I am not sure how to set an Image for its UIControlStateSelected state. I mean I would like to set an image for my segmented controls selected state. Please let me know how do I do that.
Thanks Sandy
Depending on what you want to acheive you can try the following:
- When you get a message from the control that a segment was clicked (UIControlEventValueChanged) change the image of the selected segment using the standard setImage:forSegmentAtIndex
OR
- Set the momentary property of the control to true - this was cause your buttons not to be selected.
- When you get the message that a segment was clicked replace it's image using the standard setImage:forSegmentAtIndex
Get the subviews from the segmented control until you find the correct one, and then set the image on the selected segment explicitly.
精彩评论