使 UIVIew 看起来像 IB 中的 UIView 的最佳方法?
我正在尝试制作可调整大小的 UIView,用户可以调整其大小(代码已为此完成)并拖动它。现在我需要让它看起来像 IB 中的样子,在其角上有圆圈可供拖动,虚线作为 UIView 的边框。
你认为我应该如何去做这件事?
非常感谢。
I'm trying to make resizable UIViews of which users can resize (code is done for that) and drag it around. Now I need to make it look like what it looks like in IB, with circles at its corners to drag, and dotted lines as borders of the UIView.
How do you think I should go about doing this?
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正确的方法是重写 UIView 子类(在本例中为可拖动视图)的
drawRect:
方法。您可以在以下位置查看有关进行自定义绘图的一些说明: drawrect:
祝你好运。
The proper way to do that is to override the
drawRect:
method of the UIView subclass (your draggable views in this case.)You can see some instructions for doing custom drawing at: drawrect:
Good luck.
我知道这个问题已经很老了,但我编写了一个自定义控件来实现这一点。遇到这个问题的其他人可能会发现它很有用:https://github.com/spoletto/SPUserResizingView
I know this question is pretty old, but I wrote a custom control to achieve exactly this. Someone else who happens upon this question may find it useful: https://github.com/spoletto/SPUserResizableView