UIDatePicker 的线条和字体颜色调整

[self.datePicker setValue:UIColorFromRGB(kMainColorDarkGray) forKey:@"textColor"];


// 循环获取属性的名字  property_getName函数返回一个属性的名称

unsigned int outCount;

int i;

objc_property_t *pProperty = class_copyPropertyList([UIDatePicker class], &outCount);

for (i = 0; i < outCount; i++){

NSString *getPropertyName = [NSString stringWithCString:property_getName(pProperty[i]) encoding:NSUTF8StringEncoding];

NSString *getPropertyNameString = [NSString stringWithCString:property_getAttributes(pProperty[i]) encoding:NSUTF8StringEncoding];

NSLog(@"%@====%@",getPropertyNameString,getPropertyName);

}

// 获取所有方法列表

unsigned int methCount = 0;

Method *meths = class_copyMethodList([UIDatePicker class], &methCount);

for (int i = 0 ; i < methCount; i++) {

Method meth = meths[i];

SEL sel = method_getName(meth);

const char *name = sel_getName(sel);

NSLog(@"%s",name);

}

free(meths);

*/

// 设置不显示今天

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.datePicker];

// 设置线条颜色

for (UIView *view in self.datePicker.subviews) {

if ([view isKindOfClass:[UIView class]]) {

for (UIView *subView in view.subviews) {

if (subView.frame.size.height < 1) {

subView.backgroundColor = UIColorFromRGB(kMainColorNaviBlue);

}

}

}

}

你可能感兴趣的:(UIDatePicker 的线条和字体颜色调整)