I’ve the next code in my customized UIView. This will get known as from init(body:)
or init(coder:)
initializer:
non-public func setupContentView() {
contentView = ContentView(body: .zero)
contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView)
contentView.leftAnchor.constraint(equalTo: leftAnchor, fixed:thumbWidth).isActive = true
contentView.rightAnchor.constraint(equalTo: rightAnchor, fixed: -thumbWidth).isActive = true
contentView.topAnchor.constraint(equalTo: topAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
contentView.clipsToBounds = true
contentView.isUserInteractionEnabled = true
contentView.layoutIfNeeded()
NSLog("ContentView bounds (contentView.bounds), view bounds (self.bounds)")
}
I perceive that when layoutIfNeeded
known as, it would replace contentView
body as quickly as it’s finished. However I don’t at all times see this behaviour. The NSLog
dump beneath reveals that bounds of contentView
are nonetheless 0 width and 0 top. What am I lacking?
ContentView bounds (0.0, 0.0, 0.0, 0.0), view bounds (0.0, 0.0, 774.0, 84.0)