UISegmentedControl setImage: Bug in iOS7

后端 未结 4 1768
死守一世寂寞
死守一世寂寞 2020-12-08 03:03

I have a UISegmentedControl in my app. As of iOS7 GM, the images I use are not showing up when run on iOS7 devices. Anyone else having this problem?

Here\'s what it

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 03:41

    UPDATE for Xcode 6/iOS 8

    Now you can do it in Interface builder

    Just add the image file in the asset catalog and set its "render as" original image instead of default

    Xcode 5

    The new UISegmented control uses the tint color to tint the images using the template mode. You will need to render these images as original and not templates.

    As suggested in the comments do this:

    UIImage* onceActive = [UIImage imageNamed:@"btn_onceActive"];
    if (IOS_7_MACRO)
        onceActive = [onceActive imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.theSegmentedControl setImage:onceActive forSegmentAtIndex:0];
    

提交回复
热议问题