PinLayout icon indicating copy to clipboard operation
PinLayout copied to clipboard

How can vCenter the relative view offset?

Open HParis opened this issue 6 years ago • 3 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)

HParis avatar Aug 20 '19 02:08 HParis

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

lucdion avatar Aug 20 '19 12:08 lucdion

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?

HParis avatar Aug 20 '19 15:08 HParis

import PinLayout

// ...

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

iwecon avatar Jun 17 '21 07:06 iwecon

Very old topic. Closing it, sorry

lucdion avatar Mar 01 '23 20:03 lucdion