How to set image to the UISegmentedControl in iphone?

Posted by Warrior on Stack Overflow See other posts from Stack Overflow or by Warrior
Published on 2010-06-08T21:08:25Z Indexed on 2010/06/08 21:12 UTC
Read the original article Hit count: 545

I am new to iphone development.I have created UISegmentedControl having 2 segments. I want to to display images for each segment instead of title.Here is my code

NSArray *itemArray = [NSArray arrayWithObjects: @"segment1", @"segment2", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(5,100,300,40);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.selectedSegmentIndex = 1;
[self.view addSubview:segmentedControl];
[segmentedControl release]; 

But instead of displaying the title ,segment1 and segment2 it should be replaced with the images i have.Please help me out.Thanks.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiimage