// UI要求UIDatePicker背景黑色,选中白色,并且今天
- (void)setRunDatePicck{
self.backgroundColor =[UIColor clearColor];
[selfsetDate:[NSDatedate]];
[self setMinimumDate:[NSDate date]];
unsignedintoutCount;
inti;
//获取类的所有属性
objc_property_t*pProperty =class_copyPropertyList([UIDatePickerclass], &outCount);
//获取类的所有方法
// Method *method = class_copyMethodList([UIDatePicker class],&outCount);
for(i = outCount -1; i >=0; i--)
{
// 循环获取属性的名字 property_getName函数返回一个属性的名称
NSString *getPropertyName = [NSString stringWithCString:property_getName(pProperty[i]) encoding:NSUTF8StringEncoding];
NSString *getPropertyNameString = [NSString stringWithCString:property_getAttributes(pProperty[i]) encoding:NSUTF8StringEncoding];
//获取property对应的值
// id obj = [self valueForKey:getPropertyName];
// if (obj) {
// NSLog(@"参数:%@-%@",getPropertyName,obj);
// }
if([getPropertyNameisEqualToString:@"textColor"])
{//修改背景颜色 此时今天还是黑色
[self setValue:[UIColor whiteColor] forKey:@"textColor"];
}
}
//获取方法
SEL selector = NSSelectorFromString(@"setHighlightsToday:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];
BOOLno =NO;
[invocationsetSelector:selector];
//这里的Index要从2开始,因为0跟1已经被占据了,分别是self(target),selector(_cmd)
[invocationsetArgument:&noatIndex:2];
[invocationinvokeWithTarget:self];
}