xcode 如何在 iphone 中为表格视图单元格(基于导航的应用程序)设置字体样式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10958599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:32:40  来源:igfitidea点击:

How to set font style for table view cell (navigation based app) in iphone

iphonexcode

提问by dhanjit

Please help me. How to set different font styles (stylish sentences in table view cell) programmatically for table view cell???

请帮我。如何以编程方式为表格视图单元格设置不同的字体样式(表格视图单元格中的时尚句子)???

回答by DLende

You can follow this guide for adding custom fonts on your app.

您可以按照本指南在您的应用程序中添加自定义字体。

Adding custom font on iphone

在 iphone 上添加自定义字体

Then you can call this code to set the font and font size

然后就可以调用这段代码来设置字体和字体大小

cell.textLabel.font = [UIFont fontWithName:@"custom" size:12.0f]

回答by TheTiger

You can set it with the help of UIFont see this code -

您可以在 UIFont 的帮助下进行设置,请参阅此代码 -

cell.textLabel.textColor=[UIColor whiteColor];
cell.textLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:15.0];
cell.textLabel.numberOfLines=2;
cell.textLabel.lineBreakMode=UILineBreakModeMiddleTruncation;
cell.textLabel.backgroundColor=[UIColor clearColor];

here are many property of UITableViewCell who changes it look. You can also set a UILabel on UITableViewCell like this -

这是 UITableViewCell 的许多属性,它们改变了它的外观。您还可以像这样在 UITableViewCell 上设置 UILabel -

[cell.contentView addSubview:lblView];
//lblView is your UILabel you can set its UIFont whatever you want

Thank You!!

谢谢你!!

回答by Michael Dautermann

If you are using a standard UITableViewCell, there's a "textLabel" propertythat you can access and set the font & size of (which you would do via UILabel's fontproperty).

如果您使用的是标准UITableViewCell,则可以访问textLabel”属性并设置其字体和大小(您可以通过 UILabel 的font属性进行设置)。

回答by Gerald Spreer

Starting in iOS 4, its possible to use custom fonts. This post shows how to include them into your project and how to set them on your views: http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/

从 iOS 4 开始,可以使用自定义字体。这篇文章展示了如何将它们包含到您的项目中以及如何在您的视图中设置它们:http: //blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/

回答by james

you can add the font in the following way

您可以通过以下方式添加字体

    cell.textLabel.font = [UIFont fontWithName:@"Arail" size:12.0f];

OR

或者

Give the font name as you want

根据需要提供字体名称

      cell.textLabel.font = [UIFont fontWithName:@"yourFontNameHere" size:12.0f];