gpt4 book ai didi

ios - 如何使用系统字体调整操作表元素字体的大小?

转载 作者:行者123 更新时间:2023-11-29 13:10:32 24 4
gpt4 key购买 nike

enter image description here

基本上我想创建一个带有 web View 的富文本格式编辑器。

我已经使用下面的代码检索了我设备中所有字体的名称。我现在想在我的 Web View 中选择一些文本并在其上应用该字体,因此我选择一个操作表来显示所有名称并在其上设置字体。我的问题是有些字体名称太大,并且都设置为相同的字体样式。我想将字体名称显示为字体实际样式。

// array
NSMutableArray *fontNames = [[NSMutableArray alloc] init];

// get font family
NSArray *fontFamilyNames = [UIFont familyNames];

// loop
for (NSString *familyName in fontFamilyNames)
{
NSLog(@"Font Family Name = %@", familyName);

// font names under family
NSArray *names = [UIFont fontNamesForFamilyName:familyName];

NSLog(@"INSIDE LOOP Font Names = %@", fontNames);

// add to array
[fontNames addObjectsFromArray:names];
}
NSLog(@"OUT OF LOOP Font Names = %@", fontNames);

// [fontNames release];

下面是我如何在我的 webview 选定文本上应用选择字体:

NSString *selectedButtonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
selectedButtonTitle = [selectedButtonTitle lowercaseString];

if ([actionSheet.title isEqualToString:@"Select a font"])
{
[printContentWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.execCommand('fontName', false, '%@')", selectedButtonTitle]];
}

我希望在我的操作表中有这样的输出

enter image description here

最佳答案

你的问题出在你的 UITableView 上,因为你没有发布 UIActionSheetUITableView 的代码,我创建了一个项目并将其上传到 Github ( link ),您可以找到我如何使用以下属性设法调整行文本的大小:

cell.textLabel.adjustsFontSizeToFitWidth = YES;

关于ios - 如何使用系统字体调整操作表元素字体的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17526488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com