使用Rxswift绑定两个UIview fram / Position [英] Bind two UIview fram/Position using Rxswift

查看:530
本文介绍了使用Rxswift绑定两个UIview fram / Position的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

view1 位置发生变化时,我想自动更改 view2 位置,并使用Rxswift绑定两个视图位置。

I want to change view2 position automatically when view1 position will change and bind the both view position using Rxswift.

我尝试使用此

view.rx.observe(CGRect.self,"frame")
        .subscribe(onNext: {
            print($0 ?? (0,0))
        })

在初始时打印框架,但在使用约束更改视图位置时

it print frame on init time but when change view position using constraints

self.constraintHorizontalCenterView.constant = 1000

它打印没有任何意味着此代码不会观察到视图位置...

it print nothing means this code not observe view position...

有没有办法连续观察视图位置或绑定视图位置?

Is there any way to observe continuously view position or bind view position?

推荐答案

来自apple' frame '
//可动画。如果转换视图,请不要使用框架,因为它无法正确反映视图的实际位置。改为使用边界+中心。

您可以观察到边界或居中位置。

You can observe bound or center to instead.

这篇关于使用Rxswift绑定两个UIview fram / Position的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆