- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在尽我所能地学习 Cocoa 的文本“架构”。我煞费苦心地学习了有关 NSFontDescriptor
、NSTextTab
和 NSTextView
类的所有内容,并且我认为我真正理解了它们的工作原理。然而,有一件事我似乎无法弄清楚:NSNaturalTextAlignment
。我的意思是,我明白了。据我了解,当字体的“脚本”为 RTL 时,自然对齐方式为右,而当字体的“脚本”为 LTR 时,自然对齐方式为左。所有这些都是有道理的。然而,如何确定字体脚本的自然方向呢?我问是因为我的小应用程序是如何设置的。我目前有一个迷你格式栏,其中包含常见的嫌疑人:
NSPopUpButton
用于选择字体系列NSPopUpButton
选择字体ACustomComboBox
选择字体大小NSSegmentedControl
,包含 B、I、U 等段。在这些元素之后,我有对齐控件,它也是一个 NSSegmentedControl
。其中,我有四个选项:左、居中、右和对齐。再说一遍,非常基本的东西。对齐控制的巧妙之处在于,我为每个段设置了与 NSTextAlignment
值相对应的标记。因此,当按下“左”段时,所选文本将向左对齐。对于“居中”、“正确”和“合理”也是如此。
问题在于很多时候属性字符串的 NSParagraphStyle
将返回 NSNaturalTextAlignment
值。
文档指出:
The returned value is one of the alignments described in “NSTextAlignment.”
Text using
NSNaturalTextAlignment
is actually displayed using one of the other alignments, depending on the natural alignment of the text’s script.
嗯,我很高兴 Apple 知道文本脚本的自然对齐方式,但我该如何找到它呢?我目前实现了一个非常糟糕的解决方案,但老实说我想不出任何解决办法。糟糕的解决方案如下所示:
- (void)updateTextAlignmentDisplayWithParagraphStyle:(NSParagraphStyle *)pStyle
{
NSTextAlignment alignment = pStyle.alignment;
if ( alignment == NSNaturalTextAlignment ) {
// This seems like a horrible way to determine the correct alignment ...
BOOL isRTL = ( self.textEditor.baseWritingDirection == NSWritingDirectionRightToLeft );
if ( isRTL ) {
alignment = NSRightTextAlignment;
} else {
alignment = NSLeftTextAlignment;
}
}
[self.alignmentControl selectSegmentWithTag:alignment];
}
TextView 的“基本”方向并没有真正告诉我有关字体本身方向的任何信息,但至少它暗示了字体可能的方向。我不知道。我只是感觉有一个 super secret 的 NSFontDescriptor
属性包含此信息,但我还没有找到它。 cocoa 大师,有什么建议吗?提前致谢!
最佳答案
在文件NSText.h中定义
NSNaturalTextAlignment = 4//表示脚本的默认对齐方式
我认为脚本是指书面文本的意思。
您可以使用开关(pStyle.alignment 或 self.textEditor.baseWritingDirection)更改代码,并为每个对齐方式添加 case: 。
我不是专家,但我认为,这是你需要知道的,才能继续前进。有关对齐的信息可能是字体的一部分,但这是推测性的!它也可能取自用户设置的键盘默认语言。文档或互联网中的 NSLocale 可能允许更深入地探讨这个主题。
关于objective-c - 确定 NSNaturalTextAlignment 的实际文本对齐值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22270828/
我正在使用 Selenium Web 驱动程序 3.0,并且想要从打开的两个对话框(一个在后台,第二个在前台)的 Activity 对话框中单击“确定”按钮。如何从 html 下面的父 div 单击前
actions: [ FlatButton( onPressed: () {
我有一个问题有点超出我的范围(我真的很高兴我是 Beta)涉及重复项(所以 GROUP BY, HAVING, COUNT),通过将解决方案保留在 SQLite 附带的标准函数中而变得更加复杂。我正在
使用DBI是否可以确定SELECT语句的已执行语句句柄是否返回任何行而不从中获取行? IE。就像是: use DBI; ... my $sth = $dbh->prepare("SELECT ..."
是否可以为“确定”和“关闭”按钮指定回调函数? 如果是JQuery Modal,则可以在初始化时使用按钮字典指定回调函数。 Semantic-ui模态是否提供类似的功能?按下确定后,我该如何寻求其他逻
我想阅读警报中的消息。 示例:如果警报显示“错误的电子邮件地址”。怎么读呢?意味着我想将该消息存储在字符串中。 如何在“警报”中单击“确定”...?? 如何使用 Selenium 来做到这一点? 最佳
我有一个删除按钮: 我试图首先查明是否已选择一个网站,如果已选择一个网站,我需要确定是否已选择一个或多个列表项,如果是,则继续删除这些项目。 我的 if 语句不断返回“您必须首先选择您的列表”,即使它
部分出于好奇——我们想知道在我们的应用程序中发生了什么——部分是因为我们需要在我们的代码中找到一些潜在的问题,我喜欢在我们的网络应用程序运行时跟踪一些一般值。这尤其包括某些对象图的分配内存。 我们的应
我将 SweetAlert 与 Symfony 结合使用,我希望用户在完成删除操作之前进行确认。 发生的情况是,当用户单击删除按钮时,SweetAlert 会弹出,然后立即消失,并且该项目被删除。 在
我们有一个应用程序可以生成不包括字母 O 的随机基数 35 [0-9A-Z]。我正在寻找一种解决方案来查找包含任何淫秽英语单词的代码,而无需搜索包含 10,000 个条目的列表每个生成的代码。每秒生成
这是我做的: #include #include int betweenArray(int a, int b){ int *arr,i,range; range = b - a +
我知道如何创建 警报和确认框,但我不知道如何做的是实际单击“确定”。我有一个弹出确认框的页面。 我想使用 Java Script 插件单击“确定”。基本上,我希望我的代码单击页面上的链接,然后在出现提
代码: swal('Your ORDER has been placed Successfully!!!'); window.location="index.php"; 甜蜜警报工
>>> import re >>> s = "These are the words in a sentence" >>> regex = re.compile('are|words') >>> [m
使用确定的理想散列函数给出随机期望线性时间算法两个数组 A[1..n] 和 B[1..n] 是否不相交,即 A 的元素是否也是 B 的元素。 谁能告诉我如何做到这一点,甚至如何开始考虑它? 最佳答案
我在计算机科学课上有这段代码: int input=15; while (input < n ) { input = input *3;} 这段代码有 log3(n/15) 次循环的上限。我们怎样才能
我有一个允许 2 位玩家玩 TicTacToe 的程序。在每个玩家移动之后,它应该在那个点显示棋盘并返回一个名为 Status 的枚举,显示玩家是否应该继续,如果玩家赢了,还是平局。但是,该算法要么返
给定一个 y 值数组,例如 [-3400, -1000, 500, 1200, 3790],我如何确定“好的”Y 轴标签并将它们放置在网格上? ^ ---(6,000)-|---
假设我有一个检查用户登录的 SQL 语句: SELECT * FROM users WHERE username='test@example.com', password='abc123', expi
teradata中有返回表中哪一列被定义为主索引的命令吗?我没有制作一些我正在处理的表,也没有尝试优化我对这些表的连接。谢谢! 最佳答案 有dbc.IndicesV,其中IndexNumber=1表示
我是一名优秀的程序员,十分优秀!