我正在尝试在 QT (内部标签)中创建图像,该图像会根据窗口大小的变化而改变大小,但也会保持宽高比。
最好的方法是什么?
我的xib文件中有一个TextView.
为它分配文本后,直到我双击它才会显示文本,并实际更改文本的选择:
双击之前:
双击后:

更改选择大小后:

你有什么想法,如何从一开始就显示文字?
谢谢
我正在尝试使用我创建的自定义视图。
我使用笔尖实例化,但它会导致无限循环,我不知道如何修复。任何想法?
这是运行结果的图像:
这是导致问题的代码:
// MARK: - Init & Setup
// Needed for IBDesignable
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
func setup(){
view = loadViewFromNib()
view.frame = bounds
view.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleHeight.rawValue)))
addSubview(view)
}
func loadViewFromNib() -> UIView{
let bundle = Bundle(for:type(of: self))
let nib = UINib(nibName: "LoginView", bundle: bundle) // TEST: changin bundle from bundle-> nil
let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView
return …Run Code Online (Sandbox Code Playgroud)