你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 修改toolbar裡面文字的字體和大小

iOS 修改toolbar裡面文字的字體和大小

編輯:IOS開發綜合

使用NSDictionaty來設置文本的屬性:

NSDictionary * attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Heiti SC" size:20]};
    [confirmBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal];

完整代碼:

    self.inputToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    self.inputToolbar.translucent = NO;
    self.inputToolbar.barTintColor= [UIColor colorWithRed:26.0/255.0 green:194.0/255.0 blue:97.0/255.0 alpha:1];
    self.inputToolbar.tintColor = [UIColor whiteColor];
    
    UIBarButtonItem *confirmBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Confirm" style:UIBarButtonItemStylePlain target:self action:@selector(doneKeyboard)];
    NSDictionary * attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Heiti SC" size:20]};
    [confirmBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal];
    
    UIBarButtonItem *spaceBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(doneKeyboard)];
    
    self.inputToolbar.items = [NSArray arrayWithObjects: spaceBarButton, confirmBarButton, spaceBarButton, nil];
    self.textView.inputAccessoryView = self.inputToolbar;

參考鏈接:http://stackoverflow.com/questions/2720733/how-do-you-set-the-font-size-on-a-uibarbuttonitem

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved