我想调整UITextView中字符的大小。目前可以附加字符串,但我尝试更改大小:无法实现。
在论坛中搜索后,我发现有些人选择可编辑
并取消选择它以实现更改;其他人从视图属性中选择了可选
。然后我也尝试了这两种方式,但都无法实现更改。只能使用纯文本。
import UIKit
@objc(TextControllerSwift) class TextControllerSwift: UIViewController {
var selectedMovie: String?
var textPlaying: String?
@IBOutlet weak var textMuseum: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
realPlay()
}
func playText(textSelect: String) {
textPlaying = textSelect
}
//Giving the time to Segue method to wakeup.
func realPlay(){
var textRoom: String?
//reading the file .txt
let path = NSBundle.mainBundle().pathForResource(textPlaying, ofType:"txt")
if (path != nil){
do {
textRoom= try String(contentsOfFile: path!, encoding: NSUTF8StringEncoding)
//here i'm getting the string.
}
catch {/* ignore it */}
//i tried it these options...
textMuseum.editable=true
textMuseum.selectable=true
textMuseum!.text=""
//Got the text, now i put into UiView
textMuseum.font = UIFont(name: "Arial-Unicode", size: 50)
textMuseum.text=textMuseum.text.stringByAppendingString(String(textRoom!))
}}}
我在哪里出了问题?因为我更改了文本博物馆字体。我应该在StoryBoard中放置UITextView对象并释放一些约束吗?同时,当editable
和selectable
被移除时,结果相同。为什么呢?
感谢您的每一次帮助。
编辑: 添加Git库——没有工作视频,因为我删除了这部分。要查看问题,请单击UISegmented“testo”并选择播放或表格。