所以我一直有這個問題一段時間,如果任何人都可以把我帶到正確的道路,我將不勝感激。基本上我正在製作一個應用程序,但有一個設置按鈕。每當我啓用SegmentedControl或UISWITCH時,我會回到默認狀態。另外我想要一個分段控件來改變顏色。我已經設置了顏色,但我想要更改的所有信息都在視圖控制器#1上。基本上我怎麼做一個設置頁面來保持更改。繼承我的代碼到目前爲止。通過ViewControllers傳遞數據 - 進行設置頁面
- (IBAction)colorController:(id)sender {
if (Controller.selectedSegmentIndex == 0) {
//App title text color
appTitle.textColor = [UIColor colorWithRed:1.00 green:1.00 blue:0.00 alpha:1.0];
//Background color when selected
Controller.tintColor = [UIColor colorWithRed:1.00 green:1.00 blue:0.00 alpha:1.0];
//The font of the selected
NSDictionary *fontColor = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor],NSForegroundColorAttributeName,
nil];
[Controller setTitleTextAttributes:fontColor forState:UIControlStateSelected];
}
if (Controller.selectedSegmentIndex == 1) {
//App title text color
appTitle.textColor = [UIColor colorWithRed:0.00 green:0.66 blue:1.00 alpha:1.0];
//Background color when selected
Controller.tintColor = [UIColor colorWithRed:0.00 green:0.66 blue:1.00 alpha:1.0];
//The font of the selected
NSDictionary *fontColor = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
nil];
[Controller setTitleTextAttributes:fontColor forState:UIControlStateSelected];
}
if (Controller.selectedSegmentIndex == 2) {
//App title text color
appTitle.textColor = [UIColor colorWithRed:0.98 green:0.22 blue:0.22 alpha:1.0];
//Background color when selected
Controller.tintColor = [UIColor colorWithRed:0.98 green:0.22 blue:0.22 alpha:1.0];
//The font of the selected
NSDictionary *fontColor = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
nil];
[Controller setTitleTextAttributes:fontColor forState:UIControlStateSelected];
}
if (Controller.selectedSegmentIndex == 3) {
//App title text color
appTitle.textColor = [UIColor colorWithRed:0.15 green:0.82 blue:0.44 alpha:1.0];
//Background color when selected
Controller.tintColor = [UIColor colorWithRed:0.15 green:0.82 blue:0.44 alpha:1.0];
//The font of the selected
NSDictionary *fontColor = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[Controller setTitleTextAttributes:fontColor forState:UIControlStateSelected];
}
}現在
,你可以看到「appTitle」是第一個視圖控制器上,因此它會自動不工作。我怎樣才能解決這個問題。請將我鏈接到某處/以一種不復雜的方式展示我。 (我也會有很多標籤)