objective-c - 删除 UIColor CGColor - KVC 警告

标签 objective-c ios key-value-coding kvc cgcolor

如何删除[[UIColor greyColor] CGColor]愚蠢的警告?

[self setValue:
     [[UIColor grayColor] CGColor] 
          forKeyPath:[NSString stringWithFormat:@"_View_%@%d.layer.borderColor", 
              i>=10?@"":@"0", i]];

Incompatible pointer types sending 'CGColorRef' (aka 'struct CGColor *') to parameter of type 'id'

谢谢。

最佳答案

将 CGColor 转换为 id 类型:

[self setValue:
     (id)[[UIColor grayColor] CGColor] 
          forKeyPath:[NSString stringWithFormat:@"_View_%@%d.layer.borderColor", 
              i>=10?@"":@"0", i]];

关于objective-c - 删除 UIColor CGColor - KVC 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13583644/

相关文章:

ios - 对成员 'downloadTask(with:completionHandler:)' 的模糊引用

objective-c - 如何以相反的方式对 UITableView 进行排序或添加项目?

ios - 如何对 c 结构体数组使用 NSCoding? (MK 折线)

iphone - 如何键值观察 CALayer 的旋转?

cocoa - 修改 NSArrayController 对象的值会导致错误

iphone - 我得到 : Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException' , 原因: 'Could not instantiate class named MKMapView'

objective-c - iOS:从 UIView 生成 PDF 使文本模糊

iphone - iOS7屏幕截图有白噪声

ios - 我的协议(protocol)不工作

python - 带范围的 pyobjc 索引访问器方法