【发布时间】:2017-10-10 10:29:35
【问题描述】:
我一直在为我的文本视图创建一个突出显示系统,该系统足够大,可以启用滚动,在底部我添加了一个使用子视图的按钮,它充当下一个视图的 segue。
当我使用按钮下方的功能更改文本时,按钮消失(不可点击或不可见)。 当我滚动到文本视图的顶部然后再次向下滚动时,按钮会重新出现。有谁知道为什么?有没有办法刷新按钮的显示?
编辑:子视图计数在事件之前或之后不会改变。
func highlightText () {
guard let text = self.textView.attributedText else {
return
}
guard let range = self.textView.visibleBottomRange else {
return
}
let attributedString = NSMutableAttributedString(attributedString:text)
attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.yellow , range: range)
self.textView.attributedText = attributedString
}
【问题讨论】:
标签: ios swift scroll uitextview subview