unsigned int outCount;
int i;
objc_property_t *pProperty = class_copyPropertyList([UIDatePicker class], &outCount);
for (i = outCount -1; i >= 0; i--)
{
// 循环获取属性的名字 property_getName函数返回一个属性的名称
NSString *getPropertyName = [NSString stringWithCString:property_getName(pProperty[i]) encoding:NSUTF8StringEncoding];
if([getPropertyName isEqualToString:@"textColor"])
{
[self.timePicker setValue:[UIColor whiteColor] forKey:@"textColor"];
}
}
SEL selector = NSSelectorFromString(@"setHighlightsToday:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];
BOOL no = NO;
[invocation setSelector:selector];
[invocation setArgument:&no atIndex:2];
[invocation invokeWithTarget:self.timePicker];
self.timePicker.datePickerMode = UIDatePickerModeTime; //真正想要展示的mode
[self.timePicker setValue:[UIColor whiteColor] forKey:@"textColor"];
网友评论