【发布时间】:2018-10-04 09:38:55
【问题描述】:
目标是在单击 UIButton 时更改我的 UITextView 的字体颜色和背景颜色,然后在再次单击 UIButton 时将它们恢复为原始颜色;然后重复,等等。
默认颜色设置
- 文字:
blackColor - 后台:
lightGrayColor
单击按钮时(更改为..)
- 文字:
greenColor - 后台:
blackColor
(如果再次点击,则改回默认颜色设置)
到目前为止,我有这个:
- (IBAction) enableSleepMode:(id)sender {
[txtNotes setTextColor:[UIColor greenColor]];
[txtNotes setBackgroundColor:[UIColor blackColor]];
}
我很抱歉,但我不确定从这里去哪里。提前致谢。
【问题讨论】:
-
究竟是什么不工作?该代码似乎可以将其设置为绿色/黑色?你可以做一个
if (txtNotes.textColor == [UIColor greenColor])来确定它的状态并来回交换......
标签: ios iphone uibutton uitextview