vCenter() incorrectly alters the anchor point.
MaruthiBasava opened this issue · comments
@MaruthiBasava, could you show me your view's initialization codes (ref: addSubView, ...). There is maybe an issue, but I'm unable to reproduce your issue.
If you could share the whole UIViewController class, it would be even better.
import UIKit
import PlaygroundSupport
class ViewController: UIViewController {
lazy var box1 : UIView = {
let v = UIView()
v.backgroundColor = .red
return v
}()
lazy var box2 : UIView = {
let v = UIView()
v.backgroundColor = .blue
return v
}()
lazy var box3 : UIView = {
let v = UIView()
v.backgroundColor = .green
return v
}()
lazy var box4 : UIView = {
let v = UIView()
v.backgroundColor = .red
v.alpha = 0.5
return v
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(box1)
view.addSubview(box2)
view.addSubview(box3)
view.addSubview(box4)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
box1.pin.left(10).size(100)
box2.pin.left(to: box1.edge.right)
.vCenter(to: view.edge.vCenter).size(100).marginLeft(10)
box4.pin.center(to: box2.anchor.bottomRight).size(20)
}
}
PlaygroundPage.current.liveView = ViewController()
Run this in the playground.
There is some limitation of using PinLayout in Playgrounds. See
https://github.com/layoutBox/PinLayout/blob/master/docs/xcode_playground.md
Issues was previously fixed by calling layout()
method, but looks like there is new issues 😕
Actually you're right! calling layout()
fixed my issue. Thank you so much!
Also what are other issues that may be present within the Playgrounds? My company is currently prototyping the UI on playground for efficiency, so I would love to be aware of it. Thank you once again.
Good to know, that it fixed the issue, because I was scared that there was other issue with playgrounds. ARC behave differently in playgrounds, it doesn't release object immediately, but delay their destruction.