【发布时间】:2016-01-02 05:56:57
【问题描述】:
我只是想修改 UITextView 的字符大小。直到现在可以附加字符串,但我尝试更改尺寸:是不可能的。
当我搜索论坛时,我发现有些人选择了Editable 并取消选择它。其他人通过从 View 属性中选择 Selectable 得到它。然后我尝试了这种方式......没有办法改变。只有纯文本。
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!))
}}}
嗯,我哪里错了?
因为我更改了 textMuseum 字体。我应该在 StoryBoard 中的 UITextView 对象上释放一些成本约束吗?也删除了editable 和selectable,结果是一样的。为什么?
感谢您的每一个帮助。
编辑: 添加了 Git 存储库 - 没有工作视频,因为我删除了这部分。要查看问题,只需单击 uisegmented "testo" 并选择 play 或 table。
【问题讨论】:
-
检查您的字体系列是否包含字体可用,如果可用,请检查空格和名称一次
-
@Anbu.Karthik 我更改了字体并将 HelveticaNeue (系统标准)...相同的结果。
标签: ios xcode swift fonts uitextview