I am having a problem rendering an image of a viewcontroller that has a slider with a custom uiappearance set. The image renders fine, however, the slider in the image has just the default look. If I go to that viewcontroller (vc2), the uiappearance is set to the custom look. Any ideas how to render an image with the custom slider appearance?
I have a UIImageView on the First View Controller. On the Second View Controller, I have a slider.
ViewController.m
ViewController *vc2 = [[ViewController alloc]init];
vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc2"];
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size,NO,0.0);
[vc2.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_image setImage:viewImage];
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self customizeAppearance];
// Override point for customization after application launch.
return YES;
}
- (void) customizeAppearance; {
UIImage *minImage = [[UIImage imageNamed:@"slider_minimum.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 0)];
UIImage *maxImage = [[UIImage imageNamed:@"slider_maximum.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 13)];
UIImage *thumbImage = [UIImage imageNamed:@"slider_thumb.png"];
[[UISlider appearance] setMaximumTrackImage:maxImage
forState:UIControlStateNormal];
[[UISlider appearance] setMinimumTrackImage:minImage
forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage
forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage
forState:UIControlStateHighlighted];
}