首页 > 代码库 > iOS 修改toolbar里面文字的字体和大小
iOS 修改toolbar里面文字的字体和大小
使用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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。