2011-08-17 18 views
6

मैं UISegmentedControl को अनुकूलित कर रहा हूं, लेकिन मुझे एक समस्या मिली।आईओएस में UISegmentedControl को कस्टमाइज़ कैसे करें?

UISegmentedControl में पृष्ठभूमि छवि को कैसे लागू करें? टिंट रंग बदलना मेरी आवश्यकताओं को पूरा नहीं करता है।

धन्यवाद

+0

वहाँ कई अच्छा प्रतिस्थापन यहाँ है: http://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=segmented&commit=Search – Luke

उत्तर

4

आप http://idevrecipes.com/2010/12/11/custom-segmented-controls/ की कोशिश कर सकते।

+0

मैं बस की जाँच की है, लेकिन यह काफी जटिल लगता है। क्या कोई आसान समाधान है? – user403015

+0

यदि आप एक पंजीकृत ऐप्पल डेवलपर हैं तो आईओएस 5 में UISegmentedControl के लिए शायद कुछ नए तरीके हो सकते हैं। –

5
////Segmented Controll 
NSArray *segmentTextContent = [NSArray arrayWithObjects: @"First",@"Second",@"Third",@"Forth", nil]; 
segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent]; 
segmentedControl.frame = CGRectMake(2, 5, 316, 35); 

[segmentedControl addTarget:self action:@selector(segmentAction) forControlEvents:UIControlEventValueChanged]; 
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; 
segmentedControl.enabled = true; 
segmentedControl.selectedSegmentIndex = 0; 

// cutomize the font size inside segmentedControl 
for (id segment in [segmentedControl subviews]) 
{ 
    for (id label in [segment subviews]) 
    { 
     if ([label isKindOfClass:[UILabel class]]) 
     { 
      [label setTextAlignment:UITextAlignmentCenter]; 
      [label setFont:[UIFont boldSystemFontOfSize:11]]; 
      //[label setTextColor:[UIColor greenColor]]; 
     } 
    }   
} 
संबंधित मुद्दे