2016-06-07 34 views
0

我想更改日期選取器和選取器視圖的字體大小。這可能嗎 ? 如果是?那麼它是如何完成的。如何在iOS中更改日期選取器視圖和選取器視圖的字體大小Objective C

+0

它看起來像你希望我們爲你寫一些代碼。儘管許多用戶願意爲遇險的編碼人員編寫代碼,但他們通常只在海報已嘗試自行解決問題時才提供幫助。證明這一努力的一個好方法是包含迄今爲止編寫的代碼,示例輸入(如果有的話),期望的輸出以及實際獲得的輸出(控制檯輸出,回溯等)。您提供的細節越多,您可能會收到的答案就越多。檢查[FAQ]和[問]。 – yennsarah

+0

[UiPickerView根據數據更改字體顏色]可能的副本(http://stackoverflow.com/questions/2850234/uipickerview-change-font-color-according-data) –

回答

0

不,您不能根據apple's Official site上的規定自定義UIDatepicker

因此,Developer沒有權利更改UIDatepicker。

1

對於UIDatePicker的更改附錄沒有任何API。

可以使用讓自己非常有說服力副本的UIPickerView

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 
return a;} 

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 
return b;} 

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { 

UILabel *lblpkr= [[UILabel alloc] initWithFrame:CGRectMake(p,q,r,s)]; 
[lblpkr setBackgroundColor:[UIColor clearColor]]; 
[lblpkr setTextColor:[UIColor blueColor]]; 
[lblpkr setFont:[UIFont boldSystemFontOfSize:x]]; 
[lblpkr setText:[NSString stringWithFormat:@"%d",row]]; 

return lblpkr;} 

對於斯威夫特

可定製的實施UIDatePicker

https://github.com/prolificinteractive/PIDatePicker

0

看到這個其實你可以更新使用我的字體大小thth翻滾。這是我如何更改字體

#import "UILabel+Extra.h" 

@implementation UILabel (Extra) 

-(void)layoutSubviews{ 
    [super layoutSubviews]; 

    NSArray *arrayFont = [self.font.fontName componentsSeparatedByString:@"-"]; 
    NSArray *arrayRobotoStyleName = [UIFont fontNamesForFamilyName:@"Roboto"]; 
    __block NSString *style; 
    if(arrayFont.count >= 2){ 
     [arrayRobotoStyleName enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger index, BOOL * _Nonnull stop){ 
      NSString *styleName = [arrayFont lastObject]; 
      if ([obj containsString:styleName]){ 
       style = styleName; 
       *stop = TRUE; 
      } 
      else if (index == ([arrayRobotoStyleName count] - 1)){ 
       style = @"Regular"; 
       *stop = TRUE; 
      } 
     }]; 
    } 
    else 
     style = @"Regular"; 

    if (!style) { 
     style = @"Regular"; 
    } 
    self.font = [UIFont fontWithName:[NSString stringWithFormat:@"Roboto-%@",style] size:self.font.pointSize]; 
} 

-(void)setAppearanceFont:(UIFont *)font{ 
    if (font) 
     [self setFont:font]; 
} 

-(UIFont *)appearanceFont{ 
    return self.font; 
} 
相關問題