layoutBox / PinLayout

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can vCenter the relative view offset?

HParis opened this issue · comments

How can I cover the AutoLayout like below to PinLayout.

let view1 = UIView()
let view2 = UIView()
addSubview(view1)
addSubview(view2)
        
view1.centerXAnchor.constraint(equalTo: view2.centerYAnchor, constant: -20)
view1.widthAnchor.constraint(equalTo: view2.widthAnchor, constant: -20)

What are you trying to achieve exactly @HParis? It would helps me to give you the best solution.

What are you trying to achieve exactly @HParis? It would helps me to give you the best solution.

image

The width of viewA is 80% relate the superview.

And how can I set the width of viewB is less than the width of viewA, like 20px?

commented
import PinLayout

// ...

view1.pin.width(80%)
view2.pin.width(view1.frame.width - 20).center(to: view1.anchor.center)

Very old topic. Closing it, sorry