I add the subview inside the viewDidLoad
method.
And change its attributes in the viewDidAppear
but don't success.
Really don't know why, stucking for few hour for this stupid error??!
var iv = InitView()
override func viewDidLoad() {
super.viewDidLoad()
iv.frame = view.frame
iv.hidden = true
self.navigationController!.view.addSubview(iv)
}
And in the viewDidAppear
Every attribute of this view can't change or modife
iv.hidden = false
~> doesn't work
iv.label.text = "Test"
~> Update UILabel text doesn't work either
I don't want to put these code in the viewDidLoad
because it will show the splashscreen longer as it takes.
Here is the code of InitView
class InitView:UIView {
var indicator = Indicator()
var label = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = UIColor.whiteColor()
indicator.frame = self.frame
indicator.autoresizingMask = [.FlexibleWidth,.FlexibleHeight]
self.addSubview(indicator)
self.indicator.Show()
label.translatesAutoresizingMaskIntoConstraints = false
label.textAlignment = .Center
label.text = "Loading ..."
if #available(iOS 8.2, *) {
label.font = UIFont.systemFontOfSize(17, weight: UIFontWeightLight)
} else {
// Fallback on earlier versions
label.font = UIFont.systemFontOfSize(17)
}
self.addSubview(label)
var ac = [NSLayoutConstraint]()
ac += NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[l]-0-|", options: [], metrics: nil, views: ["l":label])
ac += NSLayoutConstraint.constraintsWithVisualFormat("V:[i]-10-[l(30)]", options: [], metrics: nil, views: ["l":label,"i":indicator.container])
self.addConstraints(ac)
//self.autoresizingMask = [.FlexibleWidth,.FlexibleHeight]
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}