- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我使用 typingAttributes
设置新字体。在 iOS 10 上,一切正常,但在 iOS 11 上,第一个输入的字符是正确的,但随后属性被重置为以前的,第二个字符被输入以前的字体。这是一个错误吗?我能以某种方式修复它吗?
最佳答案
自 iOS 11 以来,Apple 更新了 typingAttributes
This dictionary contains the attribute keys (and corresponding values) to apply to newly typed text. When the text view’s selection changes, the contents of the dictionary are cleared automatically.
@Serdnad 的代码有效,但它会跳过第一个字符。这是我尝试所有可能想到的方法后的发现
<强>1。如果您只想为 TextView 使用一个通用类型属性
只需在此委托(delegate)方法中设置 typing 属性一次,您就可以使用这种单一的通用字体进行设置
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
//Set your typing attributes here
textView.typingAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.blue, NSAttributedStringKey.font.rawValue: UIFont.systemFont(ofSize: 17)]
return true
}
<强>2。在我的例子中,富文本编辑器的属性一直在变化:
在这种情况下,我每次输入任何内容后都必须设置输入属性。感谢 iOS 11 的这次更新!
但是,与其在 textViewDidChange
方法中设置,不如在 shouldChangeTextIn
方法中进行设置效果更好,因为它在将字符输入 TextView 之前被调用。
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
textView.typingAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.blue, NSAttributedStringKey.font.rawValue: UIFont.systemFont(ofSize: 17)]
return true
}
关于iOS 11 : UITextView typingAttributes reset when typing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46420230/
每次暂存文件时,如果您需要取消暂存文件,Git 都会提供有用的说明: (use "git reset HEAD ..." to unstage) 不过体面Git Tutorials by Atlass
我需要添加几个文件以将它们组合到一个提交中,但我必须排除其中一个。在 this answer ,执行此操作的代码是: git add -u git reset -- file_to_ignore.da
这个问题在这里已经有了答案: What are typical use cases of git-reset's --merge and --keep flags? (4 个答案) 关闭 6 年前。
有时候,进行了错误的提交,但是还没有push到远程分支,想要撤销本次提交,可以使用git reset –-soft/hard命令。 1、二者区别: git reset –-soft:回退到某个版
我认为:软重置:从重置向量启动。硬复位:拉CPU的电平。 最佳答案 硬复位当然意味着整个CPU芯片及其所有外设都被复位。造成这种情况的原因可能有很多:复位引脚被外部拉高、时钟故障、片内低电压检测、看门
$python manage.py reset Unknown command: 'reset' Type 'manage.py help' for usage. 在django 1.6中是否取消了这
我是 git 的新手,所以问题可能很简单,git reset --hard HEAD 和 git reset --hard 有什么区别? 最佳答案 HEAD 在您未指定该参数时是隐含的。 但是,您可以
我使用 apollo-link-state 来本地存储错误,但清除缓存后出现以下错误。 我已在 apollo 客户端配置选项中将 errors 的默认值设置为空数组 []。 但是,在 apolloCl
我正在使用 bool 数组来存储标志(类似于“已更改”)。数组的大小是静态的,在编译时已知。 我需要定期重置数组,即将所有元素设置为 false。我应该使用常规数组和类似 memset 或 memcp
在 git 文档(和许多 SO 线程)中,推荐使用这种重置方法: $ git reset --soft HEAD^ ;# go back to WIP state $ git reset
在我的实验中,我没能发现两者之间的任何功能差异 git reset --hard 和 git reset --merge 使用说明也没有给出任何提示 --hard res
如何重置所有列过滤器?调用 reset() 似乎重置了表,但过滤器的所有字段保持不变。 最佳答案 您可以将输入值绑定(bind)到表的过滤器,如下所示: 注意 [value] 绑定(bind)。 关
使用 std::unique_ptr::reset,您可以轻松地将您的实例恢复到新状态。 C++11 之前,为了实现类似的行为,我看到很多类都定义了一个 Reset() 方法来重置其所有内部成员。但现
为了恢复工作树和索引中的更改,此答案 ( https://stackoverflow.com/a/5812972/8278160) 建议运行以下命令: git reset --hard 运行它是否与运
我目前正在测试竞技场。我本来以为这段代码会编译,但在运行时失败了,令人惊喜的是,编译器发现了这个问题。但我不知道它的推理是否正确。有人能给我解释一下吗?。错误:。来自umpalo的相关代码:
我目前正在测试竞技场。我本来以为这段代码会编译,但在运行时失败了,令人惊喜的是,编译器发现了这个问题。但我不知道它的推理是否正确。有人能给我解释一下吗?。错误:。来自umpalo的相关代码:
我正在尝试在不触发“重置”事件的情况下重置我的收藏。我已经设置了我的收藏来收听“重置”和“添加”事件 @.listenTo(@options.muses, 'add', @addOne) @.list
根据http://en.cppreference.com/w/cpp/memory/unique_ptr/reset , void reset( pointer ptr = pointer() );
我有一个别名,unstage,用于从暂存区域中删除更改。 unstage = reset -- 我注意到 git 的帮助建议改为 git reset HEAD。我还注意到 git rm --cache
这个问题在这里已经有了答案: What's the difference between HEAD^ and HEAD~ in Git? (17 个答案) 关闭 6 年前。 git reset --
我是一名优秀的程序员,十分优秀!