UISegmentedControl(ã»ã°ã¡ã³ãããã³ã³ããã¼ã«)ã¯ãããã¤ãã®é ç®ã«åå²ããããã¿ã³ã管çããã¯ã©ã¹ã§ãã
UISegmentedControlãåç´ã«é ç½®ããå ´åãiOS 7.0以éã§ã¯ä¸å³ã®ããã«è¡¨ç¤ºããã¾ãã
æ¬è¨äºã§ã¯ãã»ã°ã¡ã³ãããã³ã³ããã¼ã«ãã«ã¹ã¿ãã¤ãºãã¦ã¿ã¾ãããã
ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®é ç®ã®ã¿ã¤ãã«ãå¤æ´ãã
// é ç®ã®ã¿ã¤ãã«ãå¤æ´ãã [self.segmentedControl setTitle:@"ã«ã¹ã¿ãã¤ãº" forSegmentAtIndex:0];
2çªç®ã®é ç®ãé¸æãããç¶æ ã«ãã
// 2çªç®ã®é ç®ãé¸æãããç¶æ ã«ãã self.segmentedControl.selectedSegmentIndex = 1;
ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®è²ãå¤ãã
// ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®è²ãå¤ãã self.segmentedControl.tintColor = [UIColor purpleColor];
ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®ãé¸æããã¦ããé ç®ãã®ã¿ã¤ãã«è²ãå¤æ´ãã
// ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®é¸æããã¦ããã¿ã¤ãã«ã®è²ãå¤æ´ãã NSDictionary *attributes = @{ NSForegroundColorAttributeName : [UIColor greenColor] }; [self.segmentedControl setTitleTextAttributes:attributes forState:UIControlStateSelected];
ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®ãé¸æããã¦ãã¦ããªãé ç®ãã®ã¿ã¤ãã«è²ãå¤æ´ãã
// ã»ã°ã¡ã³ãããã³ã³ããã¼ã«ã®é¸æããã¦ããªãã¿ã¤ãã«ã®è²ãå¤æ´ãã NSDictionary *attributes = @{ NSForegroundColorAttributeName : [UIColor brownColor] }; [self.segmentedControl setTitleTextAttributes:attributes forState:UIControlStateNormal];