【DoKit&北大开源实践】-【DoKit For IOS】- 相对位置插件 #828
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
相对位置插件:
在开发过程中,或进行UI后期走查的时候,可能需要确定不同插件的位置、检查其是否对齐、相对大小是否合适等,这时候就可以用到相对位置插件。
使用指南
第一步:选择Dokit面板中的相对位置插件选项
第二步:点击相对位置插件后屏幕中心会出现两个红芯圆,移动两个红芯圆到两个元素上,会在屏幕下方的窗口中显示两个控件的四个方向的边距、相对面积、各自相对于屏幕的位置;点击窗口右边的关闭按钮,即可取消相对位置确认工作。
项目代码
项目代码地址
/DoraemonKitmaster/iOS/DoraemonKitDemo/DoraemonKitDemo/Plugin
主要涉及模块有:
RelativePositionPlugin
RelativePostionManager
RelativePositionView
RelativePostionManager持有两个RelativePositionView:viewCheckViewA和
viewCheckViewB。RelativePositionView中有移动检测函数[M]touchesBegan、[M]touchesMoved、[M]touchesCancelled、[M]touchesEnded。在[M]touchesBegan、[M]touchesMoved中一旦发现needRefresh,则会调用[RelativePositionManager.shareInstance refresh]更新屏幕下方infoWindow中的信息。