使用方法:
- (IBAction)buttonClicked:(id)sender {
mybutton.backgroundColor = [UIColor blackColor];
}
我可以将黑色设置为mybutton。如何在每次单击按钮时在两种颜色之间切换?
提前Tx
答案 0 :(得分:0)
在你的h文件中初始化bool属性
@FXML
private void handleMarkovText() {
textgen.MarkovTextGenerator mtg = mainApp.getMTG();
Task<textgen.MarkovTextGenerator> task = new Task<textgen.MarkovTextGenerator>() {
@Override
public textgen.MarkovTextGenerator call() {
// process long-running computation, data retrieval, etc...
mtg.retrain(textBox.getText());
return mtg;
}
};
Dialog<Void> loadDialog = new Dialog<Void>();
loadDialog.setOnCloseRequest( e -> {
if(!task.isDone()) {
e.consume();
}
});
loadDialog.setContentText("Training MTG...");
task.setOnRunning( e -> {
ButtonType cancelButtonType = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
//Dialog<Void> loadDialog = new Dialog<Void>();
loadDialog.getDialogPane().getButtonTypes().add(cancelButtonType);
loadDialog.show();
if(task.isCancelled()) {
System.out.println("Cancelling on running");
}
});
task.setOnSucceeded(e -> {
System.out.println("Succeeded");
loadDialog.close();
textgen.MarkovTextGenerator result = task.getValue();
mainApp.showMarkovDialog(result);
// update UI with result
});
task.setOnCancelled(e -> {
System.out.println("Cancelled");
});
task.setOnFailed(e -> {
//System.out.println("failed");
});
//ProgressBar bar = new ProgressBar();
//bar.progressProperty().bind(task.progressProperty());
Thread thread = new Thread(task);
thread.start();
// train/retrain markov
// show results
}
在你的m文件中,在viewDidLoad中放入以下行
@property (nonatomic, assign) BOOL myBool;
然后在你的IBAction中,
self.myBool = YES;