开发者

How to set highlighted image in Segmented Control in iphone

开发者 https://www.devze.com 2022-12-16 19:45 出处:网络
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

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:

  1. 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

  1. Set the momentary property of the control to true - this was cause your buttons not to be selected.
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消