ios - 是不是默认背景色?

标签 ios objective-c

我想以编程方式知道,我的 TextView 具有默认背景颜色或已更改。 例如:

if (myTextView.backgroundColor == defaultColor){
NSLog(@"default");
} else {
NSLog(@"changed");
}

我有一个想法:

UITextView *etalon = [UITextVew new];
if (myTextView.backgroundColor == etalon.backgroundColor){
NSLog(@"default");
} else {
NSLog(@"changed");
}

但我觉得不太对。 有人有更好的想法吗?

最佳答案

试试这个 -

const float* color1 = CGColorGetComponents(myTextView.backgroundColor.CGColor);
const float* color2 = CGColorGetComponents(etalon.backgroundColor.CGColor);

if(color1 == color2) {
    NSLog(@"Default");
} else {
     NSLog(@"Changed");
}

关于ios - 是不是默认背景色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19726195/

相关文章:

ios - 发送到实例怪异的无法识别的选择器

ios - 在没有苹果证书的情况下发布内置于 Flash Builder 4.5 中的 iOS 移动应用程序

ios - 如何在所有 View 的顶部添加 UIView?

ios - 第三方框架与私有(private)框架?

ios - Swift - 如何获取字典的最后一个键

objective-c - CABasicAnimation 向左移动帧 300px

javascript - HTML 页面加载时发布 NSNotification

html - 在 UIWebview 中显示网页时出现对齐问题

objective-c - 从 NSFetchedResultsController 检测 sectionNameKeyPath 的更新

ios - View Controller 在 Swift 中调用 unwind segue 时卡住