且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有Storyboard的UITableViewRowAction中进行自定义字体和颜色

更新时间:2022-12-11 12:35:25

如何使用自定义字体?



这很简单。

How to use a custom font?

It's pretty easy.


  1. 首先,您需要将自定义字体文件包含在项目中。

  2. 接下来,转到到您的info.plist文件并添加一个新条目,其中包含由应用程序提供的字体键。请注意,此条目应为数组。

  3. 然后将这些文件的名称添加为此数组的元素。

  1. Firstly, you need to include your custom font files to your project.
  2. Next, go to your info.plist file and add a new entry with the key "Fonts provided by application". Note that this entry should be an Array.
  3. Then add the names of these files as elements of this array.

就是这样!你需要的只是按照这个名字使用字体

And that's it! All you need then is to use the font by its name like this

cell.textLabel.font = [UIFont fontWithName:@FontNamesize :16];

更简单。您所需要的只是

Even easier. All you need is

cell.textlabel.textcolor = UIColor.redColor()

在您的情况下,您想要更改RowAction的字体。所以我想到的只有两个解决方案。一个使用 [UIColor colorWithPatterImage:]

In your case you want to change the font of the RowAction. So I think of only 2 solutions. One to use [UIColor colorWithPatterImage:]

或者您可以使用 [[UIButton外观] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal]; 因为RowAction包含一个按钮。

Or you can user [[UIButton appearance] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal]; because the RowAction contains a button.