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);

}

}

}

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 轉至元數據結尾創建: 董瀟偉,最新修改于: 十二月 23, 2016 轉至元數據起始第一章:isa和Class一....
    40c0490e5268閱讀 1,767評論 0 9
  • 1.badgeVaule氣泡提示 2.git終端命令方法> pwd查看全部 >cd>ls >之后桌面找到文件夾內容...
    i得深刻方得S閱讀 4,736評論 1 9
  • 我們常常會聽說 Objective-C 是一門動態語言,那么這個「動態」表現在哪呢?我想最主要的表現就是 Obje...
    Ethan_Struggle閱讀 2,231評論 0 7
  • Objective-C語言是一門動態語言,它將很多靜態語言在編譯和鏈接時期做的事放到了運行時來處理。這種動態語言的...
    有一種再見叫青春閱讀 609評論 0 3
  • 因為遇見好多人,所以走丟好多人。
    yqg2227694_73d4閱讀 150評論 0 0