0

I am using UISegmentedControl (with only one segment) as a button. But problem with this is one cannot change font size in UISegmentedControl (possible in iOS-5+ but I am targeting lower versions devices). Is it possible to extract image of UISegmentedControl from app so that I can use custom UIButton with this image as background?

Any help will be appreciated.

voidStern
  • 3,678
  • 1
  • 29
  • 32
chatur
  • 2,365
  • 4
  • 24
  • 38

2 Answers2

2

try UIKit-Artwork-Extractor (look for it on github.com)

RolandasR
  • 3,030
  • 2
  • 25
  • 26
2
for (UIImageView*imgView in segmentControl.subviews) {
    UIGraphicsBeginImageContext(imgView.frame.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [segmentControl.layer renderInContext:context];
    UIImage *yourImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext(); 
}

and import QuartzCore.framework

Igor Bidiniuc
  • 1,540
  • 1
  • 16
  • 27
  • thanks for the response. This solution works in simulator but fails on device with error message -[UISegment image]: unrecognized selector sent to instance 0x1b98c0. (in my case "thisbutton" is UIsegmentedControl with number of segments 1). DO you have any idea what might be the reason? – chatur Nov 14 '11 at 11:55
  • but this UIImageView is added by you or is standart ? :) – Igor Bidiniuc Nov 14 '11 at 13:57