我使用Scrollview创建了页面结构。我使用didset更新了sectionText和HeaderText,但是无法更新图像。我需要做什么来更新图像?除了图像,一切正常。
class PageView: UIView {
var headerText: String = "" {
didSet {
headerTextField.text = headerText
}
}
var paragraphText: String = "" {
didSet {
paragraphTextView.text = paragraphText
}
}
private var cellImage = UIImageView()
var imagee: UIImage? {
didSet {
cellImage.image = imagee
}
}
class PageController: UIViewController {
let placeHolderText = "........"
let placeHolderText1 = "......"
var cellImage = UIImage(named: "asdasd")
var cellImageLogin = UIImage(named: "asdasdff")
let pageView1 = PageView(headerText: "123123", paragraphText: placeHolderText, backgroundColor: .red, image: cellImage! )
views.append(pageView1)
let pageView2 = PageView(headerText: "123213123", paragraphText: placeHolderText1, backgroundColor: .orange, image: cellImageLogin!)
views.append(pageView2)
答案 0 :(得分:0)
由于您的cellImage
没有frame
,因此在您的PageView
中不会显示
例如,您需要添加frame
cellImage.frame = CGRect(x: 0, y: 0, width: 100, height: 200)
在setup
之前的self.addSubview(cellImage)
方法中
还需要根据您的要求应用正确的约束。