简体   繁体   English

移除 UIColor CGColor - KVC 警告

[英]Remove UIColor CGColor - KVC warning

How to remove [[UIColor grayColor] CGColor] stupid warning?如何删除[[UIColor grayColor] 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'不兼容的指针类型将“CGColorRef”(又名“struct CGColor *”)发送到“id”类型的参数

thanks.谢谢。

cast CGColor to id type:将 CGColor 转换为 id 类型:

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

This will perform same as above code.这将执行与上述代码相同的操作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM